void RequestMsgProcessor::onNewSystemMsg(ShareQQMsgPtr msg) { QString gid = 0; if ( msg->type() == QQMsg::kSystemG ) { QQSystemGMsg *sysg_msg = (QQSystemGMsg *)msg.data(); gid = sysg_msg->from_uin; if ( sysg_msg->sys_g_type == "group_leave" ) { qDebug() << sysg_msg->sendUin() << "had leave group" << endl; return; } } Contact *contact = Roster::instance()->contact(msg->sendUin()); if ( !contact ) { StrangerManager *mgr = StrangerManager::instance(); contact = mgr->strangerInfo(msg->sendUin()); } if ( !contact ) { connect(StrangerManager::instance(), SIGNAL(newStrangerInfo(QString, Contact *)), this, SLOT(onNewStrangerInfo(QString, Contact *))); connect(StrangerManager::instance(), SIGNAL(newStrangerIcon(QString, QPixmap)), this, SLOT(onNewStrangerIcon(QString, QPixmap))); }
void NotifierPlugin::onNewChatMsg(ShareQQMsgPtr msg) { Notification notification; Talkable *talkable = NULL; QString sender_id; if ( msg->type() == QQMsg::kSess ) { sender_id = msg->sendUin(); talkable = StrangerManager::instance()->stranger(sender_id); } else { sender_id = msg->talkTo(); talkable = Roster::instance()->talkable(sender_id); if ( !talkable ) talkable = StrangerManager::instance()->stranger(sender_id); } QString sender_name = talkable ? talkable->markname() : sender_id; notification.title = sender_name + tr(" has new message"); notification.icon = talkable ? talkable->avatar() : QPixmap(); notification.content = msg->msg(); notification.ms_timeout = 5000; switch ( msg->type() ) { case QQMsg::kFriend: notification.type = NFT_Chat; break; case QQMsg::kGroup: notification.type = NFT_GroupChat; break; case QQMsg::kSess: notification.type = NFT_SessChat; break; } NotifyWidget *w = new NotifyWidget(notification); w->appear(); }