INT_PTR __cdecl CJabberProto::OnMenuHandleDirectPresence(WPARAM hContact, LPARAM, LPARAM res) { if (!m_bJabberOnline || !hContact) return 0; TCHAR *jid, text[1024]; ptrT tszJid(getTStringA(hContact, "jid")); if (tszJid == NULL) { ptrT roomid(getTStringA(hContact, "ChatRoomID")); if (roomid == NULL) return 0; JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, roomid); if (item == NULL) return 0; mir_sntprintf(text, _T("%s/%s"), item->jid, item->nick); jid = text; } else jid = tszJid; CMString szValue; if (EnterString(szValue, TranslateT("Status Message"), ESF_MULTILINE)) SendPresenceTo(res, jid, NULL, szValue); return 0; }
void CJabberProto::GroupchatJoinRoom( const TCHAR* server, const TCHAR* room, const TCHAR* nick, const TCHAR* password, bool autojoin ) { JabberGcRecentInfo info( this ); int i = 0; bool found = false; for (i = 0 ; i < 5; ++i) { if (!info.loadRecent(i)) continue; if (info.equals(room, server, nick, password)) { found = true; break; } } if (!found) { for (int i = 4; i--; ) { if (info.loadRecent(i)) info.saveRecent(i + 1); } info.fillData(room, server, nick, password); info.saveRecent(0); } TCHAR jid[512]; mir_sntprintf( jid, SIZEOF(jid), _T("%s@%s/%s"), room, server, nick ); JABBER_LIST_ITEM* item = ListAdd( LIST_CHATROOM, jid ); item->bAutoJoin = autojoin; replaceStr( item->nick, nick ); replaceStr( item->password, info.password ); int status = ( m_iStatus == ID_STATUS_INVISIBLE ) ? ID_STATUS_ONLINE : m_iStatus; XmlNode x( _T("x")); x << XATTR( _T("xmlns"), _T(JABBER_FEAT_MUC)); if ( info.password && info.password[0] ) x << XCHILD( _T("password"), info.password ); if (m_options.GcLogChatHistory) { HANDLE hContact = ChatRoomHContactFromJID(jid); time_t lasteventtime = JGetDword(hContact, "muc_lastevent", 0); if (hContact && lasteventtime) { TCHAR lasteventdate[40]; tmi.printTimeStamp(UTC_TIME_HANDLE, lasteventtime, _T("I"), lasteventdate, SIZEOF(lasteventdate), 0); x << XCHILD( _T("history") ) << XATTR( _T("since"), lasteventdate); } } SendPresenceTo( status, jid, x ); }
void CJabberProto::GroupchatJoinRoom(const TCHAR *server, const TCHAR *room, const TCHAR *nick, const TCHAR *password, bool autojoin) { JabberGcRecentInfo info(this); bool found = false; for (int i = 0; i < 5; i++) { if (!info.loadRecent(i)) continue; if (info.equals(room, server, nick, password)) { found = true; break; } } if (!found) { for (int i = 4; i--;) { if (info.loadRecent(i)) info.saveRecent(i + 1); } info.fillData(room, server, nick, password); info.saveRecent(0); } TCHAR text[JABBER_MAX_JID_LEN + 1]; mir_sntprintf(text, _T("%s@%s/%s"), room, server, nick); JABBER_LIST_ITEM *item = ListAdd(LIST_CHATROOM, text); item->bAutoJoin = autojoin; replaceStrT(item->nick, nick); replaceStrT(item->password, info.m_password); int status = (m_iStatus == ID_STATUS_INVISIBLE) ? ID_STATUS_ONLINE : m_iStatus; XmlNode x(_T("x")); x << XATTR(_T("xmlns"), JABBER_FEAT_MUC); if (info.m_password && info.m_password[0]) x << XCHILD(_T("password"), info.m_password); SendPresenceTo(status, text, x); }