37 const QString callButtonName = "ButtonCall"; |
37 const QString callButtonName = "ButtonCall"; |
38 const QString emailButtonName = "ButtonEmail"; |
38 const QString emailButtonName = "ButtonEmail"; |
39 const QString messageButtonName = "ButtonMessage"; |
39 const QString messageButtonName = "ButtonMessage"; |
40 const QString mycardButtonName = "ButtonMycard"; |
40 const QString mycardButtonName = "ButtonMycard"; |
41 |
41 |
42 const QString appearTL = "appear_tl"; |
42 const QString appearEffectName = "appear"; |
43 const QString appearTR = "appear_tr"; |
|
44 const QString appearBL = "appear_bl"; |
|
45 const QString appearBR = "appear_br"; |
|
46 |
43 |
47 const int commLauncherMargin = 120; // heights of titlebar & comm.launcher |
44 const int commLauncherMargin = 120; // heights of titlebar & comm.launcher |
|
45 |
|
46 // TODO: THESE STRINGS ARE IN W32 SDK. THESE DEFINITIONS CAN BE REMOVED |
|
47 // WHEN EVERYBODY ARE USING IT OR LATER VERSION |
|
48 #ifndef XQOP_CONTACTS_VIEW_CONTACT_CARD |
|
49 #define XQOP_CONTACTS_VIEW_CONTACT_CARD QLatin1String("openContactCard(int)") |
|
50 #endif |
|
51 #ifndef XQI_CONTACTS_VIEW |
|
52 #define XQI_CONTACTS_VIEW QLatin1String("com.nokia.symbian.IContactsView") |
|
53 #endif |
|
54 |
48 |
55 |
49 /*! |
56 /*! |
50 \class CommLauncherWidget |
57 \class CommLauncherWidget |
51 */ |
58 */ |
52 |
59 |
79 |
88 |
80 mLayout->setContentsMargins(horizontalMargin, verticalMargin, |
89 mLayout->setContentsMargins(horizontalMargin, verticalMargin, |
81 horizontalMargin, 2*verticalMargin); |
90 horizontalMargin, 2*verticalMargin); |
82 |
91 |
83 // create document loader |
92 // create document loader |
84 HbDocumentLoader *documentLoader = new HbDocumentLoader(); |
93 QScopedPointer<HbDocumentLoader> documentLoader ( new HbDocumentLoader() ); |
85 bool result = false; |
94 bool result = false; |
86 documentLoader->load(commLauncherDocml, &result); |
95 documentLoader->load(commLauncherDocml, &result); |
87 ASSERT(result); |
96 ASSERT(result); |
88 |
97 |
89 // create buttons |
98 // create buttons |
90 const QString callIconName = "qtg_large_active_call"; |
99 const QString callIconName = "qtg_large_active_call"; |
91 mCallButton = createButton(callIconName, callButtonName, documentLoader); |
100 mCallButton = createButton(callIconName, callButtonName, documentLoader.data()); |
|
101 HbStyle::setItemName(mCallButton, "callApp"); |
|
102 mCallButton->setObjectName("callApp"); |
92 connect(mCallButton, SIGNAL(clicked()), this, SLOT(makeCall())); |
103 connect(mCallButton, SIGNAL(clicked()), this, SLOT(makeCall())); |
93 |
104 |
94 const QString messagingIconName = "qtg_large_message"; |
105 const QString messagingIconName = "qtg_large_message"; |
95 mSendMsgButton = createButton(messagingIconName, messageButtonName, documentLoader); |
106 mSendMsgButton = createButton(messagingIconName, messageButtonName, documentLoader.data()); |
|
107 HbStyle::setItemName(mSendMsgButton, "msgApp"); |
|
108 mSendMsgButton->setObjectName("msgApp"); |
96 connect(mSendMsgButton, SIGNAL(clicked()), this, SLOT(sendMessage())); |
109 connect(mSendMsgButton, SIGNAL(clicked()), this, SLOT(sendMessage())); |
97 |
110 |
98 const QString emailIconName = "qtg_large_email"; |
111 const QString emailIconName = "qtg_large_email"; |
99 mEmailButton = createButton(emailIconName, emailButtonName, documentLoader); |
112 mEmailButton = createButton(emailIconName, emailButtonName, documentLoader.data()); |
100 // EMAIL FUNCTIONALITY COMMENTED OUT BECAUSE PLATFORM DOES NOT SUPPORT IT! |
113 HbStyle::setItemName(mEmailButton, "emailApp"); |
101 //connect(mEmailButton, SIGNAL(clicked()), this, SLOT(sendEmail())); |
114 mEmailButton->setObjectName("emailApp"); |
|
115 connect(mEmailButton, SIGNAL(clicked()), this, SLOT(sendEmail())); |
102 |
116 |
103 const QString phonebookIconName = "qtg_large_mycard"; |
117 const QString phonebookIconName = "qtg_large_mycard"; |
104 mPhonebookButton = createButton(phonebookIconName, mycardButtonName, documentLoader); |
118 mPhonebookButton = createButton(phonebookIconName, mycardButtonName, documentLoader.data()); |
|
119 HbStyle::setItemName(mPhonebookButton, "phoneApp"); |
|
120 mPhonebookButton->setObjectName("phoneApp"); |
105 connect(mPhonebookButton, SIGNAL(clicked()), this, SLOT(openPhonebook())); |
121 connect(mPhonebookButton, SIGNAL(clicked()), this, SLOT(openPhonebook())); |
106 |
122 |
107 delete documentLoader; |
123 |
108 } |
124 } |
109 |
125 |
110 /*! |
126 /*! |
111 Destructor |
127 Destructor |
112 */ |
128 */ |
113 CommLauncherWidget::~CommLauncherWidget() |
129 CommLauncherWidget::~CommLauncherWidget() |
114 { |
130 { |
115 // Deleting request cancels all pending requests |
131 // Deleting request cancels all pending requests |
116 if (mRequest) { |
|
117 delete mRequest; |
|
118 mRequest = NULL; |
|
119 } |
|
120 |
|
121 } |
132 } |
122 |
133 |
123 /*! |
134 /*! |
124 Sets the contact for the widget |
135 Sets the contact for the widget |
125 */ |
136 */ |
180 } else { |
191 } else { |
181 qDebug() << "Sms button is not created"; |
192 qDebug() << "Sms button is not created"; |
182 } |
193 } |
183 |
194 |
184 // Create email button, if email count exists |
195 // Create email button, if email count exists |
185 // EMAIL FUNCTIONALITY COMMENTED OUT BECAUSE PLATFORM DOES NOT SUPPORT IT! |
196 QList<QContactActionDescriptor> emailActionDescriptors = |
186 /*QList<QContactActionDescriptor> emailActionDescriptors = |
|
187 QContactAction::actionDescriptors("email", cmBackend); |
197 QContactAction::actionDescriptors("email", cmBackend); |
188 if (emailActionDescriptors.count() > 0) { |
198 if (emailActionDescriptors.count() > 0) { |
189 QList<QContactEmailAddress> emailList = mContact->details<QContactEmailAddress>(); |
199 QList<QContactEmailAddress> emailList = mContact->details<QContactEmailAddress>(); |
190 if (emailList.count() > 0) { |
200 if (emailList.count() > 0) { |
191 mLayout->addItem(mEmailButton); |
201 mLayout->addItem(mEmailButton); |
198 mLayout->activate(); |
208 mLayout->activate(); |
199 } |
209 } |
200 } else { |
210 } else { |
201 qDebug() << "Email button not created"; |
211 qDebug() << "Email button not created"; |
202 } |
212 } |
203 */ |
213 |
204 |
214 |
205 mLayout->addItem(mPhonebookButton); |
215 mLayout->addItem(mPhonebookButton); |
206 mButtonCount++; |
216 mButtonCount++; |
207 |
217 |
208 // add Effects |
218 // Set the disappear effect. |
209 HbEffect::add(this, QString(":/friend_expand_tl.fxml"), appearTL); |
|
210 HbEffect::add(this, QString(":/friend_expand_tr.fxml"), appearTR); |
|
211 HbEffect::add(this, QString(":/friend_expand_bl.fxml"), appearBL); |
|
212 HbEffect::add(this, QString(":/friend_expand_br.fxml"), appearBR); |
|
213 HbEffect::add(this, QString(":/friend_minimize.fxml"), "disappear"); |
219 HbEffect::add(this, QString(":/friend_minimize.fxml"), "disappear"); |
214 |
220 |
215 setLayout(mLayout); |
221 setLayout(mLayout); |
216 } |
222 } |
217 |
223 |
218 /*! |
224 /*! |
219 This widget is about to show, show effect |
225 This widget is about to show, show effect |
220 */ |
226 */ |
221 void CommLauncherWidget::popupAboutToShow() |
227 void CommLauncherWidget::popupAboutToShow() |
222 { |
228 { |
223 HbEffect::start(this, mAppearEffect); |
229 // no implementation |
224 } |
230 } |
225 |
231 |
226 /* |
232 /* |
227 * Select which appear effect to use depending on FriendWidget position |
233 * Select which appear effect to use depending on FriendWidget position |
228 */ |
234 */ |
239 } |
245 } |
240 if (LauncherPos.x() > FriendPos.x()) { |
246 if (LauncherPos.x() > FriendPos.x()) { |
241 left = false; |
247 left = false; |
242 } |
248 } |
243 |
249 |
|
250 // Remove the previous appear effect. |
|
251 if (!mAppearEffect.isEmpty()) { |
|
252 HbEffect::remove(this, mAppearEffect, appearEffectName); |
|
253 } |
|
254 |
|
255 // Define the new appear effect and set it as active appear effect. |
244 if (top && left) { |
256 if (top && left) { |
245 mAppearEffect = appearTL; |
257 mAppearEffect = ":/friend_expand_tl.fxml"; |
246 } |
258 } |
247 else if (top && !left) { |
259 else if (top && !left) { |
248 mAppearEffect = appearTR; |
260 mAppearEffect = ":/friend_expand_tr.fxml"; |
249 } |
261 } |
250 else if (!top && left) { |
262 else if (!top && left) { |
251 mAppearEffect = appearBL; |
263 mAppearEffect = ":/friend_expand_bl.fxml"; |
252 } |
264 } |
253 else { |
265 else { |
254 mAppearEffect = appearBR; |
266 mAppearEffect = ":/friend_expand_br.fxml"; |
255 } |
267 } |
|
268 HbEffect::add(this, mAppearEffect, appearEffectName); |
|
269 |
256 qDebug() << "---------------top " << top << "--- left " << left << " " << mAppearEffect; |
270 qDebug() << "---------------top " << top << "--- left " << left << " " << mAppearEffect; |
257 } |
271 } |
258 |
272 |
259 /*! |
273 /*! |
260 This widget is about to close, show effect |
274 This widget is about to close, show effect |
261 */ |
275 */ |
262 void CommLauncherWidget::popupAboutToClose() |
276 void CommLauncherWidget::popupAboutToClose() |
263 { |
277 { |
264 HbEffect::start(this, "disappear"); |
|
265 emit launcherClosed(); |
278 emit launcherClosed(); |
266 } |
279 } |
267 |
280 |
268 /*! |
281 /*! |
269 Returns a button with a given name and icon to layout |
282 Returns a button with a given name and icon to layout |
349 phoneNumber = static_cast<QContactPhoneNumber>(detail); |
364 phoneNumber = static_cast<QContactPhoneNumber>(detail); |
350 } else { |
365 } else { |
351 //if preferred is not set select the first number |
366 //if preferred is not set select the first number |
352 phoneNumber = mContact->detail<QContactPhoneNumber>(); |
367 phoneNumber = mContact->detail<QContactPhoneNumber>(); |
353 } |
368 } |
354 // invoke action |
369 // invoke action yasir memory leak |
355 QContactAction *callAction = QContactAction::action(callActionDescriptors.at(0)); |
370 |
|
371 if(mCommLauncherAction) |
|
372 delete mCommLauncherAction; |
|
373 mCommLauncherAction = QContactAction::action(callActionDescriptors.at(0)); |
|
374 mCleanupHandler.add(mCommLauncherAction); |
356 if (!phoneNumber.isEmpty()) { |
375 if (!phoneNumber.isEmpty()) { |
357 callAction->invokeAction(*mContact, phoneNumber); |
376 mCommLauncherAction->invokeAction(*mContact, phoneNumber); |
358 |
377 |
359 qDebug() << "call to number " << phoneNumber.number(); |
378 qDebug() << "call to number " << phoneNumber.number(); |
360 } |
379 } |
361 } else { |
380 } else { |
362 qDebug() << "contact has no Actions, can't make a call"; |
381 qDebug() << "contact has no Actions, can't make a call"; |
383 } else { |
402 } else { |
384 //if preferred is not set select the first number |
403 //if preferred is not set select the first number |
385 messageNumber = mContact->detail<QContactPhoneNumber>(); |
404 messageNumber = mContact->detail<QContactPhoneNumber>(); |
386 } |
405 } |
387 // invoke action |
406 // invoke action |
388 QContactAction *messageAction = QContactAction::action(messageActionDescriptors.at(0)); |
407 if(mCommLauncherAction) |
|
408 delete mCommLauncherAction; |
|
409 mCommLauncherAction = QContactAction::action(messageActionDescriptors.at(0)); |
|
410 mCleanupHandler.add(mCommLauncherAction); |
|
411 |
389 if (!messageNumber.isEmpty()) { |
412 if (!messageNumber.isEmpty()) { |
390 messageAction->invokeAction(*mContact, messageNumber); |
413 mCommLauncherAction->invokeAction(*mContact, messageNumber); |
391 |
414 |
392 qDebug() << "send to number " << messageNumber.number(); |
415 qDebug() << "send to number " << messageNumber.number(); |
393 } |
416 } |
394 } else { |
417 } else { |
395 qDebug() << "contact has no Actions, can't send a message"; |
418 qDebug() << "contact has no Actions, can't send a message"; |
399 } |
422 } |
400 |
423 |
401 /*! |
424 /*! |
402 Sends an email to contact. |
425 Sends an email to contact. |
403 */ |
426 */ |
404 // EMAIL FUNCTIONALITY COMMENTED OUT BECAUSE WK20 PLATFORM DOES NOT SUPPORT IT! |
427 |
405 |
|
406 /* |
|
407 void CommLauncherWidget::sendEmail() |
428 void CommLauncherWidget::sendEmail() |
408 { |
429 { |
409 |
430 |
410 QList<QContactActionDescriptor> emailActionDescriptors = |
431 QList<QContactActionDescriptor> emailActionDescriptors = |
411 QContactAction::actionDescriptors("email", cmBackend); |
432 QContactAction::actionDescriptors("email", cmBackend); |
412 if (emailActionDescriptors.count() > 0) { |
433 if (emailActionDescriptors.count() > 0) { |
413 QContactAction *emailAction = QContactAction::action(emailActionDescriptors.at(0)); |
434 if(mCommLauncherAction) |
|
435 delete mCommLauncherAction; |
|
436 mCommLauncherAction = QContactAction::action(emailActionDescriptors.at(0)); |
|
437 mCleanupHandler.add(mCommLauncherAction); |
414 //TODO: implement |
438 //TODO: implement |
415 QList<QContactEmailAddress> emailList = mContact->details<QContactEmailAddress>(); |
439 QList<QContactEmailAddress> emailList = mContact->details<QContactEmailAddress>(); |
416 if (emailList.count() > 0) { |
440 if (emailList.count() > 0) { |
417 emailAction->invokeAction(*mContact, emailList.at(0)); |
441 mCommLauncherAction->invokeAction(*mContact, emailList.at(0)); |
418 |
442 |
419 QString emailAddress = emailList.at(0).emailAddress(); |
443 QString emailAddress = emailList.at(0).emailAddress(); |
420 qDebug() << "send to email " << emailAddress; |
444 qDebug() << "send to email " << emailAddress; |
421 } |
445 } |
422 } else { |
446 } else { |
441 map.insert(emailSendToKey, QVariant::fromValue(emailAddress)); |
465 map.insert(emailSendToKey, QVariant::fromValue(emailAddress)); |
442 QVariant mapAsVariant = QVariant::fromValue(map); |
466 QVariant mapAsVariant = QVariant::fromValue(map); |
443 |
467 |
444 mRequest = mApplicationManager->create("com.nokia.symbian.IMessage", |
468 mRequest = mApplicationManager->create("com.nokia.symbian.IMessage", |
445 "Send", "send(QVariant)", false); |
469 "Send", "send(QVariant)", false); |
|
470 mCleanupHandler.add(mRequest); |
446 if (mRequest) { |
471 if (mRequest) { |
447 mRequest->setSynchronous(false); |
472 mRequest->setSynchronous(false); |
448 QList<QVariant> arguments; |
473 QList<QVariant> arguments; |
449 arguments.append(mapAsVariant); |
474 arguments.append(mapAsVariant); |
450 mRequest->setArguments(arguments); |
475 mRequest->setArguments(arguments); |
468 // Deleting request cancels all pending requests |
509 // Deleting request cancels all pending requests |
469 if (mRequest) { |
510 if (mRequest) { |
470 delete mRequest; |
511 delete mRequest; |
471 mRequest = NULL; |
512 mRequest = NULL; |
472 } |
513 } |
473 mRequest = mApplicationManager->create("com.nokia.services.phonebookservices", |
514 mRequest = mApplicationManager->create(XQI_CONTACTS_VIEW, |
474 "Fetch", "open(int)", false); |
515 XQOP_CONTACTS_VIEW_CONTACT_CARD, |
|
516 false); |
|
517 mCleanupHandler.add(mRequest); |
475 if (mRequest) { |
518 if (mRequest) { |
476 mRequest->setSynchronous(false); |
519 mPendingRequest = true; |
|
520 connect(mRequest, SIGNAL(requestOk(const QVariant&)), |
|
521 this, SLOT(handleRequestOk(const QVariant&))); |
|
522 mRequest->setSynchronous(false); |
477 QList<QVariant> arguments; |
523 QList<QVariant> arguments; |
478 arguments.append(QVariant(mContact->localId())); |
524 arguments.append(QVariant(mContact->localId())); |
479 mRequest->setArguments(arguments); |
525 mRequest->setArguments(arguments); |
480 bool result = mRequest->send(); |
526 bool result = mRequest->send(); |
481 if (!result) { |
527 if (!result) { |
|
528 mPendingRequest = false; |
482 qDebug() << "Sending request failed: " << mRequest->lastErrorMessage(); |
529 qDebug() << "Sending request failed: " << mRequest->lastErrorMessage(); |
483 } |
530 } |
484 } else { |
531 } else { |
485 qDebug() << "Creating service request failed"; |
532 qDebug() << "Creating service request failed"; |
486 } |
533 } |
496 // Deleting request cancels all pending requests |
543 // Deleting request cancels all pending requests |
497 if (mRequest) { |
544 if (mRequest) { |
498 delete mRequest; |
545 delete mRequest; |
499 mRequest = NULL; |
546 mRequest = NULL; |
500 } |
547 } |
501 mRequest = mApplicationManager->create("com.nokia.services.phonebookservices", |
548 |
502 "Fetch", "editCreateNew(QString,QString)", false); |
549 // Launching the phonebook to main view |
|
550 mRequest = mApplicationManager->create("com.nokia.services.phonebookappservices", |
|
551 "Launch", "launch()", false); |
|
552 mCleanupHandler.add(mRequest); |
503 if (mRequest) { |
553 if (mRequest) { |
504 QList<QVariant> arguments; |
554 QVariant retValue(-1); |
505 QString type = QContactPhoneNumber::DefinitionName; |
555 bool result = mRequest->send(retValue); |
506 arguments.append(QVariant( type )); |
556 if (!result) { |
507 arguments.append(QVariant( "" )); |
557 qDebug() << "Sending request failed: " << mRequest->lastErrorMessage(); |
508 mRequest->setArguments(arguments); |
558 } |
509 |
|
510 bool result = mRequest->send(); |
|
511 if (!result) { |
|
512 qDebug() << "Sending request failed: " << mRequest->lastErrorMessage(); |
|
513 } |
|
514 |
|
515 } else { |
|
516 qDebug() << "Creating service request failed"; |
|
517 } |
559 } |
518 } |
560 } |
519 |
561 |
520 /*! |
562 /*! |
521 Handles call key events |
563 Handles call key events |