void ChatDlgManager::openGroupChatDlg(QString id, QString gcode) { if ( isOpening(id) ) { tab_win_->activatedTab(id); tab_win_->activateWindow(); tab_win_->raise(); return; } Roster *roster = Roster::instance(); Group *group = roster->group(id); QQChatDlg *dlg = NULL; dlg = new GroupChatDlg(group); connect(dlg, SIGNAL(chatFinish(QQChatDlg*)), this, SLOT(closeChatDlg(QQChatDlg*))); if ( main_win_->recentModel() ) connect(dlg, SIGNAL(sigMsgSended(QString)), main_win_->recentModel(), SLOT(slotMsgSended(QString))); ChatMsgProcessor::instance()->registerListener(dlg); opening_chatdlg_.append(dlg); QString dlg_name = group->name().left(4); if ( group->name().size() > 4 ) dlg_name += ".."; tab_win_->addTab(dlg, dlg_name); tab_win_->show(); tab_win_->activateWindow(); tab_win_->raise(); }
void XMPPconnection::printRoster() { stringstream s; if (client->authed()) { RosterManager* rm = client->rosterManager(); Roster* r = rm->roster(); for(Roster::iterator i = r->begin(); i != r->end(); i++) { pair<string, RosterItem* > item = *i; string first = item.first; s << first; MessageWindow::getInstance().printWin(s, Log); s.str(""); s.flush(); } s << "Lista kontaktów:"; MessageWindow::getInstance().printWin(s, Log); s.str(""); s.flush(); } else { s << "Użytkownik nie jest zalogowany do serwra!"; MessageWindow::getInstance().printWin(s, Log); } }
void ChatDlgManager::openFriendChatDlg(const QString &id) { if ( isOpening(id) ) { tab_win_->activatedTab(id); tab_win_->activateWindow(); tab_win_->raise(); return; } Roster *roster = Roster::instance(); Contact *contact = roster->contact(id); if ( !contact ) contact = StrangerManager::instance()->stranger(id); QQChatDlg *dlg = NULL; dlg= new FriendChatDlg(contact); connect(dlg, SIGNAL(chatFinish(QQChatDlg*)), this, SLOT(closeChatDlg(QQChatDlg*))); if ( main_win_->recentModel() ) connect(dlg, SIGNAL(sigMsgSended(QString)), main_win_->recentModel(), SLOT(slotMsgSended(QString))); ChatMsgProcessor::instance()->registerListener(dlg); opening_chatdlg_.append(dlg); QString dlg_name = contact->name().left(4); if ( contact->name().size() > 4 ) dlg_name += ".."; tab_win_->addTab(dlg, dlg_name); tab_win_->show(); tab_win_->activateWindow(); tab_win_->raise(); }
virtual void handleMessage( const Message & msg, MessageSession * session) { m_messageEventFilter->raiseMessageEvent( MessageEventDisplayed ); m_messageEventFilter->raiseMessageEvent( MessageEventComposing ); m_chatStateFilter->setChatState( ChatStateComposing ); //这里的消息命令。都是自己定义的,用来测试的 //我在这里使用消息进行触发操作,并不代表这种操作就只能在消息中进行, //可以定义在任何的场景中 //因为是消息机制,所以,用消息代表一个命令,发过来触发流程操作 if( msg.body() == "test-buddylist" ) //遍历本地联系人列表 { Roster * roster = j->rosterManager()->roster(); Roster::const_iterator it = roster->begin(); for( ; it != roster->end(); ++it ) { printf( "jid: %s, name: %s, subscription: %d\n", (*it).second->jidJID().full().c_str(), (*it).second->name().c_str(), (*it).second->subscription() ); StringList g = (*it).second->groups(); StringList::const_iterator it_g = g.begin(); for( ; it_g != g.end(); ++it_g ) { printf( "\tgroup: %s\n", (*it_g).c_str() ); } RosterItem::ResourceMap::const_iterator rit = (*it).second->resources().begin(); for( ; rit != (*it).second->resources().end(); ++rit ) { printf( "resource: %s\n", (*rit).first.c_str() ); } } } }
virtual void roster( const Roster& roster ) { printf( "roster arriving\nitems:\n" ); RosterListener::Roster::const_iterator it = roster.begin(); for( ; it != roster.end(); ++it ) { printf( "jid: %s, name: %s, subscription: %d\n", (*it).second->jid().c_str(), (*it).second->name().c_str(), (*it).second->subscription() ); StringList g = (*it).second->groups(); StringList::const_iterator it_g = g.begin(); for( ; it_g != g.end(); ++it_g ) printf( "\tgroup: %s\n", (*it_g).c_str() ); } }
main(int argc, char **argv) { Roster r; ifstream fin; string name; if (argc != 2) { cerr << "usage: roster_main filename\n"; exit(1); } fin.open(argv[1]); if (fin.fail()) { perror(argv[1]); exit(1); } while (getline(fin, name)) r.Add_name(name); r.Print(); }
virtual void handleRoster( const Roster& roster ) { printf( "roster arriving\nitems:\n" ); Roster::const_iterator it = roster.begin(); for( ; it != roster.end(); ++it ) { printf( "jid: %s, name: %s, subscription: %d\n", (*it).second->jidJID().full().c_str(), (*it).second->name().c_str(), (*it).second->subscription() ); StringList g = (*it).second->groups(); StringList::const_iterator it_g = g.begin(); for( ; it_g != g.end(); ++it_g ) printf( "\tgroup: %s\n", (*it_g).c_str() ); RosterItem::ResourceMap::const_iterator rit = (*it).second->resources().begin(); for( ; rit != (*it).second->resources().end(); ++rit ) printf( "resource: %s\n", (*rit).first.c_str() ); } }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QTextCodec *codec = QTextCodec::codecForName("UTF-8"); QTextCodec::setCodecForCStrings(codec); QTextCodec::setCodecForLocale(codec); QTextCodec::setCodecForTr(codec); a.setApplicationName(QObject::tr("vkMp")); a.setApplicationVersion(QObject::tr("v0.1")); a.setObjectName(QObject::tr("PortveinSoft")); Roster w; w.show(); return a.exec(); }
void ADXmppProxy::handleRoster( const Roster& roster ) { //printf( "roster arriving\nitems:\n" ); Roster::const_iterator it = roster.begin(); for( ; it != roster.end(); ++it ) { /*printf( "jid: %s, name: %s, subscription: %d\n", (*it).second->jidJID().full().c_str(), (*it).second->name().c_str(), (*it).second->subscription() ); StringList g = (*it).second->groups(); StringList::const_iterator it_g = g.begin(); for( ; it_g != g.end(); ++it_g ) printf( "\tgroup: %s\n", (*it_g).c_str() ); RosterItem::ResourceMap::const_iterator rit = (*it).second->resources().begin(); for( ; rit != (*it).second->resources().end(); ++rit ) printf( "resource: %s\n", (*rit).first.c_str() );*/ BuddyList.push_back((*it).second->jidJID().full()); if(DebugLog) cout<<"ADXmppProxy::handleRoster:"<<(*it).second->jidJID().full()<<endl; } }
void Client::importRoster(const Roster &r) { for(Roster::ConstIterator it = r.begin(); it != r.end(); ++it) { importRosterItem(*it); } }