165 |
165 |
166 // ---------------------------------------------------------------------------- |
166 // ---------------------------------------------------------------------------- |
167 // LogsEvent::setRemoteParty |
167 // LogsEvent::setRemoteParty |
168 // ---------------------------------------------------------------------------- |
168 // ---------------------------------------------------------------------------- |
169 // |
169 // |
170 void LogsEvent::setRemoteParty( const QString& remoteParty ) |
170 void LogsEvent::setRemoteParty( const QString& remoteParty, bool contactMatch ) |
171 { |
171 { |
172 if ( mEventState == EventNotUpdated && mRemoteParty != remoteParty ){ |
172 if ( contactMatch ){ |
173 LOGS_QDEBUG( "logs [ENG] <-> LogsEvent::setRemoteParty, event updated") |
173 setContactMatched( !remoteParty.isEmpty() ); |
174 mEventState = LogsEvent::EventUpdated; |
174 if ( mEventState == EventNotUpdated && |
|
175 ( remoteParty.isEmpty() || mRemoteParty != remoteParty ) ){ |
|
176 mEventState = EventUpdated; |
|
177 } |
175 } |
178 } |
176 mRemoteParty = remoteParty; |
179 mRemoteParty = remoteParty; |
177 } |
180 } |
178 |
181 |
179 // ---------------------------------------------------------------------------- |
182 // ---------------------------------------------------------------------------- |
628 |
631 |
629 // ---------------------------------------------------------------------------- |
632 // ---------------------------------------------------------------------------- |
630 // |
633 // |
631 // ---------------------------------------------------------------------------- |
634 // ---------------------------------------------------------------------------- |
632 // |
635 // |
633 QString LogsEvent::updateRemotePartyFromContacts(QContactManager& manager) |
636 bool LogsEvent::updateRemotePartyFromContacts( |
634 { |
637 QContactManager& manager, QString& contactNameStr) |
|
638 { |
|
639 bool updatedRemoteParty = false; |
635 QContactDetailFilter phoneFilter; |
640 QContactDetailFilter phoneFilter; |
636 if ( mEventType == TypeVoIPCall && mLogsEventData && !mLogsEventData->remoteUrl().isEmpty() ) { |
641 if ( mEventType == TypeVoIPCall && mLogsEventData && !mLogsEventData->remoteUrl().isEmpty() ) { |
637 phoneFilter.setDetailDefinitionName( QContactOnlineAccount::DefinitionName, |
642 phoneFilter.setDetailDefinitionName( QContactOnlineAccount::DefinitionName, |
638 QContactOnlineAccount::FieldAccountUri); |
643 QContactOnlineAccount::FieldAccountUri); |
639 phoneFilter.setValue(mLogsEventData->remoteUrl()); |
644 phoneFilter.setValue(mLogsEventData->remoteUrl()); |
643 QContactPhoneNumber::FieldNumber); |
648 QContactPhoneNumber::FieldNumber); |
644 phoneFilter.setValue(mNumber); |
649 phoneFilter.setValue(mNumber); |
645 phoneFilter.setMatchFlags(QContactFilter::MatchEndsWith); |
650 phoneFilter.setMatchFlags(QContactFilter::MatchEndsWith); |
646 } else { |
651 } else { |
647 // Searching not possible |
652 // Searching not possible |
648 return QString(); |
653 return updatedRemoteParty; |
649 } |
654 } |
650 |
655 |
651 LOGS_QDEBUG_2( "logs [ENG] Try to find contact for num:", phoneFilter.value().toString() ) |
656 LOGS_QDEBUG_2( "logs [ENG] Try to find contact for num:", phoneFilter.value().toString() ) |
652 |
657 |
653 QString contactNameStr; |
|
654 QList<QContactLocalId> matchingContacts = manager.contactIds(phoneFilter); |
658 QList<QContactLocalId> matchingContacts = manager.contactIds(phoneFilter); |
655 LOGS_QDEBUG_2( "logs [ENG] Number of matches:", matchingContacts.size() ) |
659 LOGS_QDEBUG_2( "logs [ENG] Number of matches:", matchingContacts.size() ) |
656 if (matchingContacts.size() == 1) { |
660 if (matchingContacts.size() == 1) { |
657 // If multiple matches, don't dare to use any |
661 // If multiple matches, don't dare to use any |
658 QContact match = manager.contact(matchingContacts.at(0)); |
662 QContact match = manager.contact(matchingContacts.at(0)); |
659 // QContactManager::synthesiseDisplayLabel would be more clean but |
663 // QContactManager::synthesiseDisplayLabel would be more clean but |
660 // it returns currently "Unnamed" in case of missing name which we |
664 // it returns currently "Unnamed" in case of missing name which we |
661 // cannot use. |
665 // cannot use. |
662 QContactName contactName = match.detail(QContactName::DefinitionName); |
666 QContactName contactName = match.detail(QContactName::DefinitionName); |
663 contactNameStr = parseContactName(contactName); |
667 contactNameStr = parseContactName(contactName); |
664 if (contactNameStr.length() > 0){ |
668 LOGS_QDEBUG_3( "getRemotePartyFromContacts, (name, num):", contactNameStr, mNumber ); |
665 LOGS_QDEBUG_3( "getRemotePartyFromContacts, (name, num):", |
669 // Fill event with new contact info |
666 contactNameStr, mNumber ); |
670 setRemoteParty( contactNameStr, true ); |
667 // Fill event with new contact info |
671 setContactLocalId( matchingContacts.at(0) ); |
668 setRemoteParty( contactNameStr ); |
672 updatedRemoteParty = true; |
669 setContactLocalId( matchingContacts.at(0) ); |
673 } |
670 } |
674 return updatedRemoteParty; |
671 } |
|
672 return contactNameStr; |
|
673 } |
675 } |
674 |
676 |
675 // ---------------------------------------------------------------------------- |
677 // ---------------------------------------------------------------------------- |
676 // LogsEvent::parseContactName |
678 // LogsEvent::parseContactName |
677 // ---------------------------------------------------------------------------- |
679 // ---------------------------------------------------------------------------- |
692 // |
694 // |
693 // ---------------------------------------------------------------------------- |
695 // ---------------------------------------------------------------------------- |
694 // |
696 // |
695 void LogsEvent::prepareForContactMatching() |
697 void LogsEvent::prepareForContactMatching() |
696 { |
698 { |
697 // If event would be in "added" state when contact mathing is done, event state |
699 if ( contactMatched() ){ |
698 // would not go to "updated" in case of associated contact was modified or |
700 setRemoteParty(""); |
699 // new matching contact was found. This would prevent list update. |
701 setContactMatched(false); |
700 if ( mEventState == EventAdded ) { |
|
701 LOGS_QDEBUG( "logs [ENG] <-> LogsEvent::prepareForContactMatching, prepared") |
|
702 mEventState = EventNotUpdated; |
|
703 } |
702 } |
704 } |
703 } |
705 |
704 |
706 // ---------------------------------------------------------------------------- |
705 // ---------------------------------------------------------------------------- |
707 // |
706 // |