Guest User

Untitled

a guest
Jul 14th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 8.89 KB | None | 0 0
  1. diff --git CMakeLists.txt CMakeLists.txt
  2. index 0008e57..e5dc102 100644
  3. --- CMakeLists.txt
  4. +++ CMakeLists.txt
  5. @@ -10,7 +10,7 @@ set (CMAKE_MODULE_PATH
  6.  
  7.  set(KDE_MIN_VERSION "4.4.75")
  8.  find_package (KDE4 ${KDE_MIN_VERSION} REQUIRED)
  9. -find_package (TelepathyQt4 0.8.9 REQUIRED)
  10. +find_package (TelepathyQt4 0.9.1 REQUIRED)
  11.  find_package (KTp REQUIRED)
  12.  
  13.  include (CheckIncludeFiles)
  14. diff --git app/chat-window.cpp app/chat-window.cpp
  15. index 4a866ea..3b1c26a 100644
  16. --- app/chat-window.cpp
  17. +++ app/chat-window.cpp
  18. @@ -277,13 +277,8 @@ void ChatWindow::onBlockOperationFinished(Tp::PendingOperation *op)
  19.          QString errorMsg(op->errorName() + QLatin1String(": ") + op->errorMessage());
  20.          sendNotificationToUser(SystemErrorMessage, errorMsg);
  21.      }
  22. -    else { //Change the name of the action to "Unblock Contact" and disconnect it with the block slot and reconnect it with unblock slot
  23. -   QAction *action = actionCollection()->action(QLatin1String("block-contact"));
  24. -    
  25. -   disconnect(action, SIGNAL(triggered()), this, SLOT(onBlockContactTriggered()));
  26. -   action->setText(i18n("&Unblock Contact"));
  27. -    
  28. -   connect(action, SIGNAL(triggered()), this, SLOT(onUnblockContactTriggered()));
  29. +    else {
  30. +   setBlockEnabled(true);
  31.      }
  32.  }
  33.  
  34. @@ -322,6 +317,7 @@ void ChatWindow::onCurrentIndexChanged(int index)
  35.          Tp::ContactCapabilities selfCapabilities = currentChatTab->textChannel()->groupSelfContact()->capabilities();
  36.  
  37.          setAudioCallEnabled(selfCapabilities.streamedMediaAudioCalls() && contactCapabilites.streamedMediaAudioCalls());
  38. +   setBlockEnabled(currentChatTab->textChannel()->targetContact()->isBlocked());
  39.          setFileTransferEnabled(selfCapabilities.fileTransfers() && contactCapabilites.fileTransfers());
  40.          setVideoCallEnabled(selfCapabilities.streamedMediaVideoCalls() && contactCapabilites.streamedMediaVideoCalls());
  41.          setShareDesktopEnabled(s_krfbAvailableChecker->isAvailable() && contactCapabilites.streamTubes(QLatin1String("rfb")));
  42. @@ -634,6 +630,24 @@ void ChatWindow::setShareDesktopEnabled(bool enable)
  43.      }
  44.  }
  45.  
  46. +void ChatWindow::setBlockEnabled(bool blocked)
  47. +{
  48. +    QAction *action = actionCollection()->action(QLatin1String("block-contact"));
  49. +    
  50. +    if(blocked) {//Change the name of the action to "Unblock Contact" and disconnect it with the block slot and reconnect it with unblock slot
  51. +   disconnect(action, SIGNAL(triggered()), this, SLOT(onBlockContactTriggered()));
  52. +   action->setText(i18n("&Unblock Contact"));
  53. +    
  54. +   connect(action, SIGNAL(triggered()), this, SLOT(onUnblockContactTriggered()));
  55. +    }
  56. +    else {//Change the name of the action to "Block Contact" and disconnect it with the unblock slot and reconnect it with block slot
  57. +   disconnect(action, SIGNAL(triggered()), this, SLOT(onUnblockContactTriggered()));
  58. +   action->setText(i18n("&Block Contact"));
  59. +    
  60. +   connect(action, SIGNAL(triggered()), this, SLOT(onBlockContactTriggered()));
  61. +    }
  62. +}
  63. +
  64.  void ChatWindow::startAudioCall(const Tp::AccountPtr& account, const Tp::ContactPtr& contact)
  65.  {
  66.      Tp::PendingChannelRequest *channelRequest = account->ensureAudioCall(contact,
  67. @@ -721,13 +735,8 @@ void ChatWindow::onUnblockOperationFinished(Tp::PendingOperation *op)
  68.          QString errorMsg(op->errorName() + QLatin1String(": ") + op->errorMessage());
  69.          sendNotificationToUser(SystemErrorMessage, errorMsg);
  70.      }
  71. -    else { //Change the name of the action to "Block Contact" and disconnect it with the unblock slot and reconnect it with block slot
  72. -   QAction *action = actionCollection()->action(QLatin1String("block-contact"));
  73. -    
  74. -   disconnect(action, SIGNAL(triggered()), this, SLOT(onUnblockContactTriggered()));
  75. -   action->setText(i18n("&Block Contact"));
  76. -    
  77. -   connect(action, SIGNAL(triggered()), this, SLOT(onBlockContactTriggered()));
  78. +    else {
  79. +   setBlockEnabled(false);
  80.      }
  81.  }
  82.  
  83. diff --git app/chat-window.h app/chat-window.h
  84. index 7fdf379..3699401 100644
  85. --- app/chat-window.h
  86. +++ app/chat-window.h
  87. @@ -130,7 +130,8 @@ private:
  88.      void setInviteToChatEnabled(bool enable);
  89.      void setVideoCallEnabled(bool enable);
  90.      void setShareDesktopEnabled(bool enable);
  91. -
  92. +    void setBlockEnabled(bool blocked); //Sets the block/unblock action according to the blocked flag
  93. +    
  94.      /** starts audio call with given contact
  95.       * @param account account sending the audio call request
  96.       * @param contact contact with whom to start audio call
  97. diff --git lib/channel-contact-model.cpp lib/channel-contact-model.cpp
  98. index d731322..fa33ac7 100644
  99. --- lib/channel-contact-model.cpp
  100. +++ lib/channel-contact-model.cpp
  101. @@ -112,6 +112,17 @@ void ChannelContactModel::onContactAliasChanged(const QString &alias)
  102.      Q_EMIT contactAliasChanged(contact, alias);
  103.  }
  104.  
  105. +
  106. +void ChannelContactModel::onContactBlockStatusChanged(bool blocked)
  107. +{
  108. +    Tp::ContactPtr contact(qobject_cast<Tp::Contact*>(sender()));
  109. +
  110. +    QModelIndex index = createIndex(m_contacts.lastIndexOf(contact), 0);
  111. +    Q_EMIT dataChanged(index, index);
  112. +
  113. +    Q_EMIT contactBlockStatusChanged(contact, blocked);
  114. +}
  115. +
  116.  void ChannelContactModel::addContacts(const Tp::Contacts &contacts)
  117.  {
  118.      QList<Tp::ContactPtr> newContacts = contacts.toList();
  119. @@ -119,6 +130,7 @@ void ChannelContactModel::addContacts(const Tp::Contacts &contacts)
  120.      Q_FOREACH(Tp::ContactPtr contact, newContacts) {
  121.          connect(contact.data(), SIGNAL(aliasChanged(QString)), SLOT(onContactAliasChanged(QString)));
  122.          connect(contact.data(), SIGNAL(presenceChanged(Tp::Presence)), SLOT(onContactPresenceChanged(Tp::Presence)));
  123. +   connect(contact.data(), SIGNAL(blockStatusChanged(bool)), SLOT(onContactBlockStatusChanged(bool)));
  124.      }
  125.  
  126.      beginInsertRows(QModelIndex(), m_contacts.size(), m_contacts.size() + newContacts.size());
  127. @@ -135,7 +147,8 @@ void ChannelContactModel::removeContacts(const Tp::Contacts &contacts)
  128.          //if we don't disconnect could we still get notifications here about their status/presence changes even if a contact has left the room
  129.          disconnect(contact.data(), SIGNAL(aliasChanged(QString)), this, SLOT(onContactAliasChanged(QString)));
  130.          disconnect(contact.data(), SIGNAL(presenceChanged(Tp::Presence)), this, SLOT(onContactPresenceChanged(Tp::Presence)));
  131. -
  132. +   disconnect(contact.data(), SIGNAL(blockStatusChanged(bool)), this, SLOT(onContactBlockStatusChanged(bool)));
  133. +  
  134.          beginRemoveRows(QModelIndex(), m_contacts.indexOf(contact), m_contacts.indexOf(contact));
  135.          m_contacts.removeAll(contact);
  136.          endRemoveRows();
  137. diff --git lib/channel-contact-model.h lib/channel-contact-model.h
  138. index 41d5d84..d62ef98 100644
  139. --- lib/channel-contact-model.h
  140. +++ lib/channel-contact-model.h
  141. @@ -47,6 +47,7 @@ public:
  142.  Q_SIGNALS:
  143.      void contactPresenceChanged(const Tp::ContactPtr &contact, const KTp::Presence &presence);
  144.      void contactAliasChanged(const Tp::ContactPtr &contact, const QString &alias);
  145. +    void contactBlockStatusChanged(const Tp::ContactPtr &contact, bool blocked);
  146.  
  147.  protected:
  148.      int rowCount(const QModelIndex &parent) const;
  149. @@ -60,6 +61,7 @@ private Q_SLOTS:
  150.                               const Tp::Channel::GroupMemberChangeDetails &details);
  151.      void onContactPresenceChanged(const Tp::Presence &presence);
  152.      void onContactAliasChanged(const QString &alias);
  153. +    void onContactBlockStatusChanged(bool blocked);
  154.  
  155.  
  156.  private:
  157. diff --git lib/chat-widget.cpp lib/chat-widget.cpp
  158. index bb1f5ef..dce35f4 100644
  159. --- lib/chat-widget.cpp
  160. +++ lib/chat-widget.cpp
  161. @@ -400,6 +400,8 @@ void ChatWidget::setupContactModelSignals()
  162.              SLOT(onContactPresenceChange(Tp::ContactPtr,KTp::Presence)));
  163.      connect(d->contactModel, SIGNAL(contactAliasChanged(Tp::ContactPtr,QString)),
  164.              SLOT(onContactAliasChanged(Tp::ContactPtr,QString)));
  165. +    connect(d->contactModel, SIGNAL(contactBlockStatusChanged(Tp::ContactPtr,bool)),
  166. +       SLOT(onContactBlockStatusChanged(Tp::ContactPtr,bool)));
  167.  }
  168.  
  169.  
  170. @@ -806,6 +808,15 @@ void ChatWidget::onContactAliasChanged(const Tp::ContactPtr & contact, const QSt
  171.      }
  172.  }
  173.  
  174. +
  175. +void ChatWidget::onContactBlockStatusChanged(const Tp::ContactPtr &contact, bool blocked)
  176. +{
  177. +    //TODO: Add the chatview logic
  178. +    
  179. +    Q_EMIT contactBlockStatusChanged(blocked);
  180. +    
  181. +}
  182. +
  183.  void ChatWidget::onChannelInvalidated()
  184.  {
  185.      setChatEnabled(false);
  186. diff --git lib/chat-widget.h lib/chat-widget.h
  187. index e1efbbb..5dd6691 100644
  188. --- lib/chat-widget.h
  189. +++ lib/chat-widget.h
  190. @@ -119,6 +119,8 @@ protected Q_SLOTS:
  191.      void onContactPresenceChange(const Tp::ContactPtr &contact, const KTp::Presence &presence);
  192.  
  193.      void onContactAliasChanged(const Tp::ContactPtr &contact, const QString &alias);
  194. +    
  195. +    void onContactBlockStatusChanged(const Tp::ContactPtr &contact, bool blocked);
  196.  
  197.      void onChannelInvalidated();
  198.  
  199. @@ -143,7 +145,9 @@ Q_SIGNALS:
  200.      void userTypingChanged(Tp::ChannelChatState);
  201.  
  202.      void contactPresenceChanged(KTp::Presence presence);
  203. -
  204. +    
  205. +    void contactBlockStatusChanged(bool blocked);
  206. +    
  207.      void unreadMessagesChanged();
  208.  
  209.      /** Emitted when a notification for the chat window has been activated*/
Add Comment
Please, Sign In to add comment