void EntryBase::CheckVCardUpdate (const QXmppPresence& pres) { auto conn = Account_->GetClientConnection (); if (!conn->GetInfoReqPolicyManager ()->IsRequestAllowed (InfoRequest::VCard, this)) return; auto fetchVCard = [this, conn] () -> void { QPointer<EntryBase> ptr (this); conn->FetchVCard (GetJID (), [ptr] (const QXmppVCardIq& iq) { if (ptr) ptr->SetVCard (iq); }); }; const auto& vcardUpdate = pres.vCardUpdateType (); if (vcardUpdate == QXmppPresence::VCardUpdateNoPhoto) { if (!Avatar_.isNull ()) { Avatar_ = QImage (); emit avatarChanged (GetAvatar ()); } } else if (vcardUpdate == QXmppPresence::VCardUpdateValidPhoto) { if (pres.photoHash () != VCardPhotoHash_) fetchVCard (); } else if (pres.type () == QXmppPresence::Available && !HasBlindlyRequestedVCard_) { fetchVCard (); HasBlindlyRequestedVCard_ = true; } }
Protocol::Protocol(const char *aName, const TCHAR *descr) { mir_strncpy(name, aName, _countof(name)); mir_tstrncpy(description, descr, _countof(description)); data_changed = true; // Load services int caps = CallProtoService(name, PS_GETCAPS, PFLAGNUM_1, 0); if (caps & PF1_IM) valid = true; else return; can_have_listening_to = (ProtoServiceExists(name, PS_SET_LISTENINGTO) != 0); PF3 = CallProtoService(name, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0); caps = CallProtoService(name, PS_GETCAPS, PFLAGNUM_4, 0); can_have_avatar = (caps & PF4_AVATARS) != 0; can_set_nick = ProtoServiceExists(name, PS_SETMYNICKNAME) != FALSE; // Initial value GetStatus(); GetStatusMsg(); GetNick(); GetAvatar(); }
void MRIMBuddy::HandleWPInfo (const QMap<QString, QString>& values) { VCardDialog *dia = new VCardDialog (); dia->setAttribute (Qt::WA_DeleteOnClose); dia->SetInfo (values); dia->SetAvatar (GetAvatar ()); dia->show (); }
void RoomParticipantEntry::SetPhotoHash (const QByteArray& hash) { VCardPhotoHash_ = hash; if (hash.isEmpty ()) Avatar_ = QImage (); else { Avatar_ = Core::Instance ().GetAvatarsStorage ()->GetAvatar (hash.toHex ()); if (Avatar_.isNull ()) VCardPhotoHash_.clear (); } emit avatarChanged (GetAvatar ()); }
void NotificationsManager::HandleMessage (IMessage *msg) { const bool showMsg = XmlSettingsManager::Instance () .property ("ShowMsgInNotifications").toBool (); const auto other = qobject_cast<ICLEntry*> (msg->OtherPart ()); const auto parentCL = qobject_cast<ICLEntry*> (msg->ParentCLEntry ()); QString msgString; bool isHighlightMsg = false; switch (msg->GetMessageType ()) { case IMessage::Type::ChatMessage: if (XmlSettingsManager::Instance () .property ("NotifyAboutIncomingMessages").toBool ()) { if (!showMsg) msgString = tr ("Incoming chat message from <em>%1</em>.") .arg (other->GetEntryName ()); else { const auto& body = msg->GetEscapedBody (); const auto& notifMsg = body.size () > 50 ? body.left (50) + "..." : body; msgString = tr ("Incoming chat message from <em>%1</em>: <em>%2</em>") .arg (other->GetEntryName ()) .arg (notifMsg); } } break; case IMessage::Type::MUCMessage: { isHighlightMsg = Core::Instance ().IsHighlightMessage (msg); if (isHighlightMsg && XmlSettingsManager::Instance () .property ("NotifyAboutConferenceHighlights").toBool ()) { if (!showMsg) msgString = tr ("Highlighted in conference <em>%1</em> by <em>%2</em>.") .arg (parentCL->GetEntryName ()) .arg (other->GetEntryName ()); else { const auto& body = msg->GetEscapedBody (); const auto& notifMsg = body.size () > 50 ? body.left (50) + "..." : body; msgString = tr ("Highlighted in conference <em>%1</em> by <em>%2</em>: <em>%3</em>") .arg (parentCL->GetEntryName ()) .arg (other->GetEntryName ()) .arg (notifMsg); } } break; } default: return; } auto e = Util::MakeNotification ("Azoth", msgString, PInfo_); if (msgString.isEmpty ()) e.Mime_ += "+advanced"; auto entry = msg->GetMessageType () == IMessage::Type::MUCMessage ? parentCL : other; BuildNotification (e, entry); const auto count = ++UnreadCounts_ [entry]; if (msg->GetMessageType () == IMessage::Type::MUCMessage) { e.Additional_ ["org.LC.Plugins.Azoth.SubSourceID"] = other->GetEntryID (); e.Additional_ ["org.LC.AdvNotifications.EventType"] = isHighlightMsg ? AN::TypeIMMUCHighlight : AN::TypeIMMUCMsg; e.Additional_ ["NotificationPixmap"] = QVariant::fromValue (other->GetAvatar ()); if (isHighlightMsg) e.Additional_ ["org.LC.AdvNotifications.FullText"] = tr ("%n message(s) from", 0, count) + ' ' + other->GetEntryName () + " <em>(" + parentCL->GetEntryName () + ")</em>"; else e.Additional_ ["org.LC.AdvNotifications.FullText"] = tr ("%n message(s) in", 0, count) + ' ' + parentCL->GetEntryName (); } else { e.Additional_ ["org.LC.AdvNotifications.EventType"] = AN::TypeIMIncMsg; e.Additional_ ["org.LC.AdvNotifications.FullText"] = tr ("%n message(s) from", 0, count) + ' ' + other->GetEntryName (); } e.Additional_ ["org.LC.AdvNotifications.Count"] = count; e.Additional_ ["org.LC.AdvNotifications.ExtendedText"] = tr ("%n message(s)", 0, count); e.Additional_ ["org.LC.Plugins.Azoth.Msg"] = msg->GetEscapedBody (); const auto nh = new Util::NotificationActionHandler { e, this }; nh->AddFunction (tr ("Open chat"), [parentCL] { Core::Instance ().GetChatTabsManager ()->OpenChat (parentCL, true); }); nh->AddDependentObject (parentCL->GetQObject ()); EntityMgr_->HandleEntity (e); }
bool Protocol::HasAvatar() { GetAvatar(); return avatar_bmp != NULL; }