Skip to content

Commit

Permalink
Merge branch 'jb51477' into 'master'
Browse files Browse the repository at this point in the history
[commhistoryd] Hide call and reply notification actions without phone number. Fixes JB#51477

See merge request mer-core/commhistory-daemon!45
  • Loading branch information
jpetrell committed Oct 9, 2020
2 parents 3669b0f + 55d0c89 commit 53f8dca
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 35 deletions.
77 changes: 42 additions & 35 deletions src/notificationmanager.cpp
Expand Up @@ -633,29 +633,34 @@ void NotificationManager::setNotificationProperties(Notification *notification,
if (pn->eventType() == CommHistory::Event::IMEvent
|| pn->eventType() == CommHistory::Event::SMSEvent
|| pn->eventType() == CommHistory::Event::MMSEvent) {
// Named action: "Reply"
remoteActions.append(dbusAction(QString(),
txt_qtn_msg_notification_reply,
MESSAGING_SERVICE_NAME,
OBJECT_PATH,
MESSAGING_INTERFACE,
START_CONVERSATION_METHOD,
QVariantList() << pn->account()
<< pn->targetId()
<< true));

if (pn->eventType() == CommHistory::Event::IMEvent || pn->hasPhoneNumber()) {
// Named action: "Reply"
remoteActions.append(dbusAction(QString(),
txt_qtn_msg_notification_reply,
MESSAGING_SERVICE_NAME,
OBJECT_PATH,
MESSAGING_INTERFACE,
START_CONVERSATION_METHOD,
QVariantList() << pn->account()
<< pn->targetId()
<< true));
}
}

if (pn->eventType() == CommHistory::Event::SMSEvent
|| pn->eventType() == CommHistory::Event::MMSEvent
|| pn->eventType() == VOICEMAIL_SMS_EVENT_TYPE) {
// Named action: "Call"
remoteActions.append(dbusAction(QString(),
txt_qtn_msg_notification_call,
VOICECALL_SERVICE,
VOICECALL_OBJECT_PATH,
VOICECALL_INTERFACE,
VOICECALL_DIAL_METHOD,
QVariantList() << pn->remoteUid()));
if (pn->hasPhoneNumber()) {
// Named action: "Call"
remoteActions.append(dbusAction(QString(),
txt_qtn_msg_notification_call,
VOICECALL_SERVICE,
VOICECALL_OBJECT_PATH,
VOICECALL_INTERFACE,
VOICECALL_DIAL_METHOD,
QVariantList() << pn->remoteUid()));
}
}

break;
Expand All @@ -679,23 +684,25 @@ void NotificationManager::setNotificationProperties(Notification *notification,
CALL_HISTORY_METHOD,
QVariantList() << CALL_HISTORY_PARAMETER));

remoteActions.append(dbusAction(QString(),
txt_qtn_call_notification_call_back,
VOICECALL_SERVICE,
VOICECALL_OBJECT_PATH,
VOICECALL_INTERFACE,
VOICECALL_DIAL_METHOD,
QVariantList() << pn->remoteUid()));

remoteActions.append(dbusAction(QString(),
txt_qtn_call_notification_send_message,
MESSAGING_SERVICE_NAME,
OBJECT_PATH,
MESSAGING_INTERFACE,
START_CONVERSATION_METHOD,
QVariantList() << pn->account()
<< pn->targetId()
<< true));
if (pn->hasPhoneNumber()) {
remoteActions.append(dbusAction(QString(),
txt_qtn_call_notification_call_back,
VOICECALL_SERVICE,
VOICECALL_OBJECT_PATH,
VOICECALL_INTERFACE,
VOICECALL_DIAL_METHOD,
QVariantList() << pn->remoteUid()));

remoteActions.append(dbusAction(QString(),
txt_qtn_call_notification_send_message,
MESSAGING_SERVICE_NAME,
OBJECT_PATH,
MESSAGING_INTERFACE,
START_CONVERSATION_METHOD,
QVariantList() << pn->account()
<< pn->targetId()
<< true));
}

break;

Expand Down
8 changes: 8 additions & 0 deletions src/personalnotification.cpp
Expand Up @@ -297,6 +297,14 @@ bool PersonalNotification::hidden() const
return false;
}

bool PersonalNotification::hasPhoneNumber() const
{
if (m_eventType == CommHistory::Event::SMSEvent || m_eventType == CommHistory::Event::MMSEvent || m_eventType == VOICEMAIL_SMS_EVENT_TYPE) {
return CommHistory::normalizePhoneNumber(m_remoteUid, true).length() > 0;
}
return false;
}

void PersonalNotification::setRemoteUid(const QString& remoteUid)
{
if (m_remoteUid != remoteUid) {
Expand Down
2 changes: 2 additions & 0 deletions src/personalnotification.h
Expand Up @@ -116,6 +116,8 @@ class PersonalNotification : public QObject, public Serialisable
QDateTime timestamp() const;
bool hidden() const;

bool hasPhoneNumber() const;

void setRemoteUid(const QString& remoteUid);
void setAccount(const QString& account);
void setEventType(uint eventType);
Expand Down

0 comments on commit 53f8dca

Please sign in to comment.