/* priave session handling functions, called by libmeanwhile callbacks */ void MeanwhileSession::handleSessionStateChange( enum mwSessionState state, gpointer data) { HERE; this->state = state; switch (state) { case mwSession_STARTING: case mwSession_HANDSHAKE: case mwSession_HANDSHAKE_ACK: case mwSession_LOGIN: case mwSession_LOGIN_CONT: case mwSession_LOGIN_ACK: break; case mwSession_LOGIN_REDIR: handleRedirect((char *)data); break; case mwSession_STARTED: { struct mwUserStatus stat = { mwStatus_ACTIVE, 0, 0L }; mwSession_setUserStatus(session, &stat); struct mwLoginInfo *logininfo = mwSession_getLoginInfo(session); if (logininfo) { account->myself()->setNickName(getNickName(logininfo)); } syncContactsFromServer(); } break; case mwSession_STOPPING: { unsigned int info = GPOINTER_TO_UINT(data); if (info & ERR_FAILURE) { if (info == INCORRECT_LOGIN) account->password().setWrong(); char *reason = mwError(info); emit serverNotification(QString(reason)); free(reason); } } emit sessionStateChange( static_cast<MeanwhileProtocol *>(account->protocol()) ->statusOffline); break; case mwSession_STOPPED: break; case mwSession_UNKNOWN: default: mwDebug() << "Unhandled state change " << state << endl; } }
void __cdecl SessionStateChange(mwSession* session, mwSessionState state, gpointer info) { CSametimeProto* proto = (CSametimeProto*)mwSession_getProperty(session, "PROTO_STRUCT_PTR"); proto->debugLog(_T("SessionStateChange() state=[%d]"), state); switch (state) { case mwSession_STARTING: break; case mwSession_HANDSHAKE: break; case mwSession_HANDSHAKE_ACK: break; case mwSession_STARTED: proto->SessionStarted(); break; case mwSession_STOPPING: if ((int)info) {// & ERR_FAILURE) { char *msg = mwError((int)info); TCHAR *msgT = mir_utf8decodeT(msg); proto->showPopup(TranslateTS(msgT), SAMETIME_POPUP_ERROR); mir_free(msgT); g_free(msg); } proto->SessionStopping(); break; case mwSession_STOPPED: break; case mwSession_LOGIN_REDIR: proto->debugLog(_T("SessionStateChange() mwSession_LOGIN_REDIR info=[%s]"), _A2T((char*)info)); //options.server_name = str((char*)info); strcpy(proto->options.server_name, (char*)info); proto->LogOut(); proto->LogIn(proto->login_status, proto->m_hNetlibUser); break; case mwSession_LOGIN_CONT: break; case mwSession_LOGIN: break; case mwSession_LOGIN_ACK: break; case mwSession_UNKNOWN: break; } }
struct mwReturnCodeDesc *mwGetReturnCodeDesc(guint32 code) { struct mwReturnCodeDesc *rcDesc = g_new(struct mwReturnCodeDesc, 1); if (code & ERR_FAILURE) rcDesc->type = mwReturnCodeError; else rcDesc->type = mwReturnCodeInfo; rcDesc->codeString = g_strdup(err_to_str(code)); rcDesc->name = mwError(code); rcDesc->description = mwErrorDesc(code); return rcDesc; }
/** A conversation has been closed */ void mwIm_conversation_closed(mwConversation *conv, guint32 err) { if(err & ERR_FAILURE && err != CONNECTION_RESET) { char *msg = mwError(err); TCHAR *ts = u2t(msg); //MessageBox(0, ts, TranslateT("Sametime Error"), MB_OK | MB_ICONWARNING); ShowError(TranslateTS(ts)); g_free(msg); free(ts); } mwIdBlock *idb = mwConversation_getTarget(conv); HANDLE hContact = FindContactByUserId(idb->user); if(hContact) { ContactMessageQueue::iterator i; EnterCriticalSection(&q_cs); if((i = contact_message_queue.find(hContact)) != contact_message_queue.end()) { contact_message_queue.erase(i); } LeaveCriticalSection(&q_cs); } }