void Contact::update() { std::string s=(nickname.empty())? jid.getBareJid():nickname; std::string resource=jid.getResource(); clientIcon=0; if(Config::getInstance()->confclient){/* if(wcsstr(utf8::utf8_wchar(getClientIdIcon()).c_str(),L"bombus-im.org/ng")!=NULL){clientIcon=icons::ICON_BOMBUS_NG;}else{ if(wcsstr(utf8::utf8_wchar(getClientIdIcon()).c_str(),L"tkabber")!=NULL){clientIcon=icons::ICON_TKAB;}else{ if(wcsstr(utf8::utf8_wchar(getClientIdIcon()).c_str(),L"bombusmod-qd")!=NULL){clientIcon=icons::ICON_BOMBUS_QD;}else{ if(wcsstr(utf8::utf8_wchar(getClientIdIcon()).c_str(),L"gajim")!=NULL){clientIcon=icons::ICON_GAJIM;}else{ if(wcsstr(utf8::utf8_wchar(getClientIdIcon()).c_str(),L"Siemens Native Jabber Client")!=NULL){clientIcon=icons::ICON_SJC;}else{ if(wcsstr(utf8::utf8_wchar(getClientIdIcon()).c_str(),L"qip")!=NULL){clientIcon=icons::ICON_QIP;}else{ if(wcsstr(utf8::utf8_wchar(getClientIdIcon()).c_str(),L"pidgin")!=NULL){clientIcon=icons::ICON_PIDGIN;}else{ if(wcsstr(utf8::utf8_wchar(getClientIdIcon()).c_str(),L"miranda")!=NULL){clientIcon=icons::ICON_MIRANDA;}else{ if(wcsstr(utf8::utf8_wchar(getClientIdIcon()).c_str(),L"kopete")!=NULL){clientIcon=icons::ICON_KOPET;}else{ if(wcsstr(utf8::utf8_wchar(getClientIdIcon()).c_str(),L"bombus-im.org/java")!=NULL){clientIcon=icons::ICON_BOMBUS;}else{ if(wcsstr(utf8::utf8_wchar(getClientIdIcon()).c_str(),L"psi")!=NULL){clientIcon=icons::ICON_PSI;}else{ if(wcsstr(utf8::utf8_wchar(getClientIdIcon()).c_str(),L"bombusmod.net.ru")!=NULL){clientIcon=icons::ICON_BOMBUSMOD;}else{ if(wcsstr(utf8::utf8_wchar(getClientIdIcon()).c_str(),L"bombusng-qd.googlecode.com")!=NULL){clientIcon=icons::ICON_BOMBUS_QD_NG; }else{ clientIcon=0; }}}}}}}}}}}}}}*/ Skin * il= dynamic_cast<Skin *>(skin.get()); std::string ClientI=getClientIdIcon(); if(ClientI.length()>2 ){if (il) clientIcon=il->getKlientIndex((char*)ClientI.c_str());}else clientIcon=0; } if (resource.length()) { s+='/'; s+=resource; } wjid=utf8::utf8_wchar( s ); init(); }
int identifyTransport(const std::string &jid) { int serv=jid.find('@')+1; int dotsrv=jid.find('.', serv); if (dotsrv<0) return 0; Skin * il= dynamic_cast<Skin *>(skin.get()); if (!il) return 0; return il->getBaseIndex(jid.substr(serv, dotsrv-serv)); }
ProcessResult ProcessMuc::blockArrived(JabberDataBlockRef block, const ResourceContextRef rc){ JabberDataBlockRef xmuc=block->findChildNamespace("x", "http://jabber.org/protocol/muc#user"); if (!xmuc) return BLOCK_REJECTED; const std::string &from=block->getAttribute("from"); const std::string &type=block->getAttribute("type"); Jid roomNode; roomNode.setJid(from); std::string message; //1. group MucGroup::ref roomGrp; roomGrp=boost::dynamic_pointer_cast<MucGroup> (rc->roster->findGroup(roomNode.getBareJid())); if (!roomGrp) return BLOCK_PROCESSED; //dropped presence MucContact::ref c=getMucContactEntry(from, rc); MPA action=NONE; if (type=="error") { JabberDataBlockRef error=block->getChildByName("error"); int errCode=atoi(error->getAttribute("code").c_str()); //todo: if (status>=Presence.PRESENCE_OFFLINE) testMeOffline(); action=LEAVE; //todo: if (errCode!=409 || status>=Presence.PRESENCE_OFFLINE) setStatus(presenceType); std::string errText=error->getChildText("text"); if (errText.length()>0) message=errText; // if error description is provided by server else // legacy codes switch (errCode) { case 401: message="Password required"; case 403: message="You are banned in this room"; case 404: message="Room does not exists"; case 405: message="You can't create room on this server"; case 406: message="Reserved roomnick must be used"; case 407: message="This room is members-only"; case 409: message="Nickname is already in use by another occupant"; case 503: message="Maximum number of users has been reached in this room"; default: message=*(error->toXML()); } } else { JabberDataBlockRef item=xmuc->getChildByName("item"); MucContact::Role role = getRoleIndex(item->getAttribute("role")); c->sortKey=MucContact::MODERATOR-role; MucContact::Affiliation affiliation = getAffiliationIndex(item->getAttribute("affiliation")); boolean roleChanged= c->role != role; boolean affiliationChanged= c->affiliation !=affiliation; c->role=role; c->affiliation=affiliation; //setSortKey(nick); switch (role) { case MucContact::MODERATOR: c->transpIndex=icons::ICON_MODERATOR_INDEX; break; case MucContact::VISITOR: { Skin * il= dynamic_cast<Skin *>(skin.get()); c->transpIndex=(il)? il->getBaseIndex("visitors") : 0; break; } default: c->transpIndex=0; } JabberDataBlockRef statusBlock=xmuc->getChildByName("status"); int statusCode=(statusBlock)? atoi(statusBlock->getAttribute("code").c_str()) : 0; message=c->jid.getResource(); // nick if (type=="unavailable") { action=LEAVE; std::string reason=item->getChildText("reason"); switch (statusCode) { case 303: message+=" is now known as "; message+=item->getAttribute("nick"); c->jid.setResource(item->getAttribute("nick")); c->rosterJid=c->jid.getJid(); //for vCard c->update(); action=NONE; break; case 307: //kick case 301: //ban message+=(statusCode==307)?" was kicked " : " was banned "; message+="("; message+=reason; message+=")"; if (c->realJid.length()>0){ message+=" - "; message+=c->realJid; } break; case 321: message+=" has been unaffiliated and kicked from members-only room"; break; case 322: message+=" has been kicked because room became members-only"; break; default: { message+=" has left the channel"; const std::string & status=block->getChildText("status"); if (status.length()) { message+=" ("; message+=status; message+=")"; } } } } else { //onlines action=ENTER; if (c->status>=presence::OFFLINE) { // first online std::string realJid=item->getAttribute("jid"); if (realJid.length()) { c->realJid=realJid; message+=" ("; message+=realJid; //for moderating purposes message+=")"; } message+=" has joined the channel as "; message+=roleName[role]; if (affiliation!=MucContact::NONE) { message+=" and "; message+=affiliationName[affiliation-MucContact::OUTCAST]; const std::string & status=block->getChildText("status"); if (status.length()) { message+=" ("; message+=status; message+=")"; } } } else { //change status message+=" is now "; if ( roleChanged ) message+=roleName[role]; if (affiliationChanged) { if (roleChanged) message+=" and "; message+=(affiliation==MucContact::NONE)? "unaffiliated" : affiliationName[affiliation-MucContact::OUTCAST]; } if (!roleChanged && !affiliationChanged) { const std::string &show=block->getChildText("show"); if (show.length()==0) message+="online"; else message+=show; const std::string & status=block->getChildText("status"); if (status.length()) { message+=" ("; message+=status; message+=")"; } } } } } if (c.get()==roomGrp->selfContact.get()) { switch (action) { case ENTER: // room contact is online roomGrp->room->status=presence::ONLINE; break; case LEAVE: // room contact is offline roomGrp->room->status=presence::OFFLINE; // make all occupants offline rc->roster->setStatusByFilter(roomNode.getBareJid(), presence::OFFLINE); break; } } { ChatView *cv = dynamic_cast<ChatView *>(tabs->getWindowByODR(c).get()); bool ascroll=(cv==NULL)? false: cv->autoScroll(); c->processPresence(block); if (ascroll) { cv->moveEnd(); } if (cv) if (IsWindowVisible(cv->getHWnd())) cv->redraw(); } rc->roster->makeViewList(); { Message::ref msg=Message::ref(new Message(message, from, false, Message::PRESENCE, Message::extractXDelay(block) )); Contact::ref room=roomGrp->room; ChatView *cv = dynamic_cast<ChatView *>(tabs->getWindowByODR(room).get()); bool ascroll=(cv==NULL)? false: cv->autoScroll(); room->messageList->push_back(msg); if (ascroll) { cv->moveEnd(); } if (cv) if (IsWindowVisible(cv->getHWnd())) cv->redraw(); } return BLOCK_PROCESSED; }