Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
kanaksony
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha
Accepted Solution

Add to AddressBook - Add Image

[ Edited ]

Hi,

 

I am adding contact to AddressBook. Info are added well, but adding Photo to Contact is not working. I am trying to add a static image to Contact. There are some Faillure messages in console...

 

Debug: extractNewPhotos: primary photo file: "file://asset:///images/avatar.png" id: 0
Debug: [DEBUG] received notification for unified contact, notification name: "contact_new"
Debug: [DEBUG] received contact ids: (QVariant(int, 14) )
Debug: [DEBUG] sent contactNew signal for contact id: (14)
Debug: Open Success:
Debug: Session Details "https://discoveryservice.blackberry.com/discoveryPoxmlServlet/" "3fb64670-0400-4485-8494-fdb44fb5d1c7" "1.0" "127.0.0.1" 8888
Debug: POST
Debug: URL Buffer: http://127.0.0.1:8888/contacts/4?enterprise=0

Debug: Curl Easy perform - dab
Debug: [DEBUG] received notification for unified contact, notification name: "contact_new"
Debug: [DEBUG] received contact ids: (QVariant(int, 15) )
Debug: [DEBUG] sent contactNew signal for contact id: (15)
Debug: Curl Easy GetInfo response code
Debug: Curl easy getInfo content_length_download
Debug: Curl Error Code 0
Debug: Response Code 200
Debug: Form Data json=%7B%22filepath%22%3A%22asset%3A%2F%2F%2Fimages%2Favatar.png%22%7D
Debug: POST
Debug: URL Buffer: http://127.0.0.1:8888/contact/4/15/photos

Debug: Curl Easy perform - dab
Debug: Curl Easy GetInfo response code
Debug: Curl easy getInfo content_length_download
Debug: Curl Error Code 0
Debug: Response Code 500
Debug: Status Code 500
Debug: Exception String 'An unexpected problem occured with %(account)s. Some features may not be working correctly.' % {'status': 500}
Debug: getContactDtails called 15
Debug: GET
Debug: URL Buffer: http://127.0.0.1:8888/contact/4/15

Debug: Curl Easy perform - dab
Debug: Curl Easy GetInfo response code
Debug: Curl easy getInfo content_length_download
Debug: Curl Error Code 0
Debug: Response Code 200

 

Code is : 

 

ContactService* service = new ContactService(this);
	ContactBuilder builder;
   
   QVariantMap photoMap  = directoryMap.value("photos").toList()[0].toMap();
	if( photoMap.count()>0 ) {
			ContactPhoto photo = ContactPhotoBuilder()
								.setOriginalPhoto("/images/avatar.png");
		builder.addPhoto(photo);
	}
	bb::pim::contacts::Contact createdContact = service->createContact(builder, false);
	if (createdContact.id()){
                   qDebug() << "--------addToNAB------"<<"DONE..!!";
}

 

EDIT : Same issues I am having while adding Postal Address. I guess these features are not working right now..

 

 

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Retired
PBernhardt
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30

Re: Add to AddressBook - Add Image

Can you please log a bug on the DIT? Once you do, let me know and I'll make sure it gets dealt with right away.

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Developer
kanaksony
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: Add to AddressBook - Add Image

Hi Paul, I have logged issue on DIT. 

 

https://www.blackberry.com/jira/browse/BBTEN-381

 

Any other having same issue please upvote this.

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Developer
nimithingu
Posts: 37
Registered: ‎09-04-2012
My Device: Blackberry 10 Dev Alpha

Re: Add to AddressBook - Add Image

HI,

 

I am also getting error when adding a contact with only textual information did you find a way however I am trying in simulator i dont understand what the issue might be as I have followed the tutorial of Contact API

 

Here is the debug log that i get

 

Created instance of PIMCoreStatusManager 
 PIMCoreStatusManager Constructor 
extractNewPhotos: primary photo file:  ""   id:  0 
[DEBUG] received notification for unified contact, notification name:  "contact_new" 
[DEBUG] received contact ids:  (QVariant(int, 1) )  
[DEBUG] sent contactsAdded signal for contact id:  (1) 
Open Success: 
Session Details   "https://discoveryservice.blackberry.com/discoveryPoxmlServlet/"   "380b7e76-41a1-41e3-8f69-9ae50069e3b2"   "1.0"   "127.0.0.1"   8888 
POST   
URL Buffer: http://127.0.0.1:8888/contacts/4?enterprise=0 
 
Curl Easy perform 
Curl Easy GetInfo response code 
Curl easy getInfo content_length_download 
Curl Error Code 0 
Response Code 500 
Status Code 500 
Exception String An unexpected problem occured with Unified Contacts. Some features may not be working correctly. 
Error occurred! Investigate!  createContactHelper  L 428 
path passed in: 
icon path: 

 

Here is my code in c++ file.

 

void PeopleFinder::addToContact(){

	ContactService service;

	// Create the builder objects, which are used to create the contact, postal
	// address, and home phone number
	ContactBuilder contactBuilder;
	ContactAttributeBuilder attributeBuilder;

	if (selectedPerson["givenName"].toString() != NULL) {
		qDebug() << "Name: " << selectedPerson["givenName"].toString();
		// Create the First name
		ContactAttribute firstname =
				ContactAttributeBuilder().setKind(AttributeKind::Name).setSubKind(
						AttributeSubKind::NameGiven).setValue(
						selectedPerson["givenName"].toString());
		contactBuilder.addAttribute(firstname);
	}

	if (selectedPerson["sn"].toString() != NULL) {
		// Create the Last name
		ContactAttribute surname =
				ContactAttributeBuilder().setKind(AttributeKind::Name).setSubKind(
						AttributeSubKind::NameSurname).setValue(
						selectedPerson["sn"].toString());
		contactBuilder.addAttribute(surname);
	}
	if (selectedPerson["telephoneNumber"].toString() != NULL) {
		// Create the work phone number
		ContactAttribute workphone =
				ContactAttributeBuilder().setKind(AttributeKind::Phone).setSubKind(
						AttributeSubKind::Work).setValue(
						selectedPerson["telephoneNumber"].toString());
		contactBuilder.addAttribute(workphone);
	}
	if (selectedPerson["mobile"].toString() != NULL) {
		// Create the mobile
		ContactAttribute mobile =
				ContactAttributeBuilder().setKind(AttributeKind::Phone).setSubKind(
						AttributeSubKind::PhoneMobile).setValue(
						selectedPerson["mobile"].toString());
		contactBuilder.addAttribute(mobile);
	}
	if (selectedPerson["email"].toString() != NULL) {
		// Create the email
		ContactAttribute email =
				ContactAttributeBuilder().setKind(AttributeKind::Email).setSubKind(
						AttributeSubKind::Work).setValue(
						selectedPerson["email"].toString());
		contactBuilder.addAttribute(email);
	}
	if (selectedPerson["extFunction"].toString() != NULL) {
		// Create the Function
		ContactAttribute function = ContactAttributeBuilder().setKind(
				ContactAttributeBuilder().determineAttributeKind(
						"P&G Function")).setValue(
				selectedPerson["extFunction"].toString());
		contactBuilder.addAttribute(function);
	}
	if (selectedPerson["uid"].toString() != NULL) {
		// Create the USERID
		ContactAttribute uid =
				ContactAttributeBuilder().setKind(
						ContactAttributeBuilder().determineAttributeKind(
								"P&G UserID")).setValue(
						selectedPerson["uid"].toString());
		contactBuilder.addAttribute(uid);
	}

	// Add the contact to the database
	Contact createdContact = service.createContact(contactBuilder, false);

	showToast("Contact Added successfully!");

}

 Can you help is the code having issue..?

 

 

 

Developer
nimithingu
Posts: 37
Registered: ‎09-04-2012
My Device: Blackberry 10 Dev Alpha

Re: Add to AddressBook - Add Image

OK once I removed the Address code and also the determineAttributeKind feature is not working.
Developer
kanaksony
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: Add to AddressBook - Add Image

OK, I got a reply from PBernhardt, for adding Address - 

 

"This is actually a documentation issue. You need to set the sub kind on the postal address." It should be like .setSubKind(AttributeSubKind::Work) or Home or Other

 

Fix required is  : ContactPostalAddressBuilder(address).setSubKind(AttributeSubKind::Work);

 

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Developer
nimithingu
Posts: 37
Registered: ‎09-04-2012
My Device: Blackberry 10 Dev Alpha

Re: Add to AddressBook - Add Image

Yes this fix worked Thanks.

New Contributor
allagi
Posts: 3
Registered: ‎01-17-2013
My Device: BB10 Alpha Dev B

Re: I am also facing same issue... while sending email

I am getting the below error...

 

Curl Easy perform
Curl Easy GetInfo response code
Curl easy getInfo content_length_download
Curl Error Code 0
Response Code 200
Account id : 199
Message : ""
PIMCoreAccessPool::getPca 0 Thread Id 0x1
PIMCoreAccessPool::getPca a new PimAccess 0
Form Data bcc=%5B%22%5C%22Test%20Act3%5C%22%20%3CTestAct3%40hotmail.com%3E%22%5D&body=Testing%20email%20body&body_content_type=text%2Fplain%3B%20charset%3Dutf-8&cc=%5B%22%5C%22Test%20Act2%5C%22%20%3CTestAct2%40yahoo.com%3E%22%5D&encoding_action=0&encoding_type=0&options=%7B%22flagged%22%3Afalse%2C%22priority%22%3A%221%22%7D&subject=Test%20Subject%20&to=%5B%22%5C%22rajesh.allagi%40accenture.com%5C%22%20%3Crajesh.allagi%40accenture.com%3E%22%5D
post data &colon; "bcc=%5B%22%5C%22Test%20Act3%5C%22%20%3CTestAct3%40hotmail.com%3E%22%5D&body=Testing%20email%20body&body_content_type=text%2Fplain%3B%20charset%3Dutf-8&cc=%5B%22%5C%22Test%20Act2%5C%22%20%3CTestAct2%40yahoo.com%3E%22%5D&encoding_action=0&encoding_type=0&options=%7B%22flagged%22%3Afalse%2C%22priority%22%3A%221%22%7D&subject=Test%20Subject%20&to=%5B%22%5C%22rajesh.allagi%40accenture.com%5C%22%20%3Crajesh.allagi%40accenture.com%3E%22%5D"
POST
URL Buffer: http://127.0.0.1:8888/mail/message/199/send

Curl Easy perform
Curl Easy GetInfo response code
Curl easy getInfo content_length_download
Curl Error Code 0
Response Code 500
Status Code 500
Exception String Message rejected by plugin
ErrorInfo MessageServicePrivate::handleResponse Message rejected by plugin : 500 methodid MSIP::send
PIMCoreAccessPool::returnPca 1
Message Sent : 0

 

 

The above error I am getting for the below code..

 

MessageService service;
// Initialize the current account if there is any
Account currentAccount;
const QList<Account> accounts = AccountService().accounts(
Service::Messages);
if (!accounts.isEmpty())
currentAccount = accounts.first();

MessageBuilder *builder = MessageBuilder::create(currentAccount.id());
qDebug() << "Account id : " << currentAccount.id();

QString subject = "Test Subject ";
MessageContact rto = MessageContact(-1, MessageContact::To, "", email);

QByteArray bodyData = "Testing email body";
builder->subject(subject);
bool added;
builder->addRecipient(rto, &added);

builder->body(MessageBody::smileytongue:lainText, bodyData);

Message message = *builder;
qDebug() << "Message : "<<message.errorDetails();
MessageKey key = service.send(currentAccount.id(), message);

qDebug() << "Message Sent : " << key;

 

 

Please let me know if any solution to the above problem.

 

Thanks,

Rajesh

 

New Contributor
allagi
Posts: 3
Registered: ‎01-17-2013
My Device: BB10 Alpha Dev B

Re: I am also facing same issue... while sending email

Hi,

 

Any solution to the above issue?. This issue is only on personal side, where as the same code works fine on work side.  Please let me know if any one has faced the same issue and has the solution to the problem.

 

Thanks in advance.

 

Regards,

Rajesh

Retired
PBernhardt
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30

Re: I am also facing same issue... while sending email

This thread is solved and you are talking about a separate issue with a different API. Please create a new thread.

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker