Пример #1
0
void CDropbox::CommandDelete(void *arg)
{
	CommandParam *param = (CommandParam*)arg;

	char *path = (char*)param->data;
	if (path == NULL) {
		CMStringA error(FORMAT, T2Utf(TranslateT("\"%s\" command has invalid parameter.\nUse \"/help\" for more info.")), "/delete");
		ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hProcess, 0);
		CallContactService(param->instance->GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)error.GetBuffer());

		return;
	}
	ptrA token(db_get_sa(NULL, MODULE, "TokenSecret"));
	ptrA encodedPath(mir_utf8encode(path));
	DeleteRequest request(token, encodedPath);
	NLHR_PTR response(request.Send(param->instance->hNetlibConnection));

	if (response == NULL || response->resultCode != HTTP_STATUS_OK) {
		ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hProcess, 0);
		return;
	}

	JSONNode root = JSONNode::parse(response->pData);
	if (root.empty()) {
		ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hProcess, 0);
		return;
	}

	bool isDeleted = root.at("is_deleted").as_bool();
	CMStringA message(FORMAT, "%s %s", path, !isDeleted ? T2Utf(TranslateT("is not deleted")) : T2Utf(TranslateT("is deleted")));
	ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hProcess, 0);
	CallContactService(param->instance->GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)message.GetBuffer());
}
Пример #2
0
int CMraProto::SendMsg(MCONTACT hContact, int, const char *lpszMessage)
{
    if (!m_bLoggedIn) {
        ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)"You cannot send when you are offline.");
        return 0;
    }

    DWORD dwFlags = 0;
    CMStringW wszMessage(ptrW(mir_utf8decodeT(lpszMessage)));
    if (wszMessage.IsEmpty()) {
        ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)"Cant allocate buffer for convert to unicode.");
        return 0;
    }

    CMStringA szEmail;
    if (!mraGetStringA(hContact, "e-mail", szEmail))
        return 0;

    BOOL bSlowSend = getByte("SlowSend", MRA_DEFAULT_SLOW_SEND);
    if (getByte("RTFSendEnable", MRA_DEFAULT_RTF_SEND_ENABLE) && (MraContactCapabilitiesGet(hContact) & FEATURE_FLAG_RTF_MESSAGE))
        dwFlags |= MESSAGE_FLAG_RTF;

    int iRet = MraMessage(bSlowSend, hContact, ACKTYPE_MESSAGE, dwFlags, szEmail, wszMessage, NULL, 0);
    if (bSlowSend == FALSE)
        ProtoBroadcastAckAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)iRet, 0);
    return iRet;
}
Пример #3
0
void CDropbox::CommandShare(void *arg)
{
	CommandParam *param = (CommandParam*)arg;

	char *path = (char*)param->data;
	if (path == NULL) {
		CMStringA error(FORMAT, T2Utf(TranslateT("\"%s\" command has invalid parameter.\nUse \"/help\" for more info.")), "/share");
		ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hProcess, 0);
		CallContactService(param->instance->GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)error.GetBuffer());

		return;
	}

	ptrA token(db_get_sa(NULL, MODULE, "TokenSecret"));
	ptrA encodedPath(mir_utf8encode(path));
	bool useShortUrl = db_get_b(NULL, MODULE, "UseSortLinks", 1) > 0;
	ShareRequest request(token, encodedPath, useShortUrl);
	NLHR_PTR response(request.Send(param->instance->hNetlibConnection));

	if (response == NULL || response->resultCode != HTTP_STATUS_OK) {
		ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hProcess, 0);
		return;
	}

	JSONNode root = JSONNode::parse(response->pData);
	if (root.empty()) {
		ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hProcess, 0);
		return;
	}

	CMStringA link = root.at("url").as_string().c_str();
	ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hProcess, 0);
	CallContactService(param->instance->GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)link.GetBuffer());
}
Пример #4
0
int CVkProto::SetStatus(int iNewStatus)
{
	if (m_iDesiredStatus == iNewStatus || iNewStatus == ID_STATUS_IDLE)
		return 0;

	int oldStatus = m_iStatus;
	m_iDesiredStatus = iNewStatus;

	if (iNewStatus == ID_STATUS_OFFLINE) {
		if ( IsOnline()) {
			SetServerStatus(ID_STATUS_OFFLINE);
			ShutdownSession();
		}

		m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
		ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
	}
	else if (m_hWorkerThread == NULL && !(m_iStatus >= ID_STATUS_CONNECTING && m_iStatus < ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)) {
		m_iStatus = ID_STATUS_CONNECTING;
		ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
		m_hWorkerThread = ForkThreadEx(&CVkProto::WorkerThread, 0, NULL);
	}
	else if ( IsOnline())
		SetServerStatus(iNewStatus);
	else 
		ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);

	return 0;
}
Пример #5
0
void __cdecl CYahooProto::search_simplethread(void *snsearch)
{
	TCHAR *id = (TCHAR *) snsearch;

	if (lstrlen(id) < 4) {
		ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
		MessageBoxA(NULL, "Please enter a valid ID to search for.", "Search", MB_OK);
		return;
	}

	TCHAR *c = _tcschr(id, '@');
	if (c) *c = 0;

	PROTOSEARCHRESULT psr = { 0 };
	psr.cbSize = sizeof(psr);
	psr.flags = PSR_TCHAR;
	psr.id = (TCHAR*)_tcslwr(id);
	psr.reserved[0] = YAHOO_IM_YAHOO;

	ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE) 1, (LPARAM) & psr);

	//yahoo_search(m_id, YAHOO_SEARCH_YID, m, YAHOO_GENDER_NONE, YAHOO_AGERANGE_NONE, 0, 1);

	ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
}
Пример #6
0
int CMraProto::SendContacts(MCONTACT hContact, int, int nContacts, MCONTACT *hContactsList)
{
    INT_PTR iRet = 0;

    if (m_bLoggedIn && hContact) {
        BOOL bSlowSend;
        CMStringW wszData, wszEmail;
        CMStringA szEmail;
        if (mraGetStringA(hContact, "e-mail", szEmail)) {
            for (int i = 0; i < nContacts; i++) {
                if (IsContactMra(hContactsList[i]))
                    if (mraGetStringW(hContactsList[i], "e-mail", wszEmail))
                        wszData += wszEmail + ';' + pcli->pfnGetContactDisplayName(hContactsList[i], 0) + ';';
            }

            bSlowSend = getByte("SlowSend", MRA_DEFAULT_SLOW_SEND);
            iRet = MraMessage(bSlowSend, hContact, ACKTYPE_CONTACTS, MESSAGE_FLAG_CONTACT, szEmail, wszData, NULL, 0);
            if (bSlowSend == FALSE)
                ProtoBroadcastAck(hContact, ACKTYPE_CONTACTS, ACKRESULT_SUCCESS, (HANDLE)iRet, 0);
        }
    }
    else ProtoBroadcastAck(hContact, ACKTYPE_CONTACTS, ACKRESULT_FAILED, NULL, (LPARAM)"You cannot send when you are offline.");

    return iRet;
}
Пример #7
0
void CVkProto::OnReceiveAvatar(NETLIBHTTPREQUEST *reply, AsyncHttpRequest* pReq)
{
	if (reply->resultCode != 200 || !pReq->pUserInfo)
		return;

	PROTO_AVATAR_INFORMATION ai = { 0 };
	CVkSendMsgParam * param = (CVkSendMsgParam *)pReq->pUserInfo;
	GetAvatarFileName(param->hContact, ai.filename, _countof(ai.filename));
	ai.format = ProtoGetBufferFormat(reply->pData);

	FILE *out = _tfopen(ai.filename, _T("wb"));
	if (out == NULL) {
		ProtoBroadcastAck(param->hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, &ai);
		delete param;
		pReq->pUserInfo = NULL;
		return;
	}

	fwrite(reply->pData, 1, reply->dataLength, out);
	fclose(out);
	setByte(param->hContact, "NeedNewAvatar", 0);
	ProtoBroadcastAck(param->hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, &ai);
	delete param;
	pReq->pUserInfo = NULL;
}
Пример #8
0
void CYahooProto::ext_got_search_result(int found, int start, int total, YList *contacts)
{
	struct yahoo_found_contact *yct=NULL;
	int i=start;
	YList *en=contacts;

	LOG(("got search result: "));
	
	LOG(("Found: %d", found));
	LOG(("Start: %d", start));
	LOG(("Total: %d", total));
		
	PROTOSEARCHRESULT psr = { 0 };
	psr.cbSize = sizeof(psr);
	psr.flags = PSR_TCHAR;
	psr.reserved[0] = YAHOO_IM_YAHOO;
	
	while (en) {
		yct = ( yahoo_found_contact* )en->data;

		if (yct == NULL) {
			LOG(("[%d] Empty record?",i++));
		} else {
			LOG(("[%d] id: '%s', online: %d, age: %d, sex: '%s', location: '%s'", i++, yct->id, yct->online, yct->age, yct->gender, yct->location));
			psr.id = mir_utf8decodeT( yct->id );
			
			if (yct->gender[0] != 5)
				psr.firstName = mir_utf8decodeT( yct->gender );
			else
				psr.firstName = NULL;
			
			TCHAR c[10];
			if (yct->age > 0) {
				_itot(yct->age, c,10);
				psr.lastName = ( TCHAR* )c;
			}
			else
				psr.lastName = NULL;
			
			if (yct->location[0] != 5)
				psr.email = mir_utf8decodeT( yct->location );
			else
				psr.email = NULL;
    
			//void yahoo_search(int id, enum yahoo_search_type t, const char *text, enum yahoo_search_gender g, enum yahoo_search_agerange ar, 
			//	int photo, int yahoo_only)

			ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE) 1, (LPARAM) & psr);

			mir_free(psr.id);
			mir_free(psr.firstName);
			mir_free(psr.email);
		}
		en = y_list_next(en);
	}
	ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
}
Пример #9
0
void CSametimeProto::UserRecvAwayMessage(MCONTACT hContact)
{
	debugLog(_T("CSametimeProto::UserRecvAwayMessage() start hContact=[%x]"), hContact);
	DBVARIANT dbv;
	if (!db_get_s((MCONTACT)hContact, "CList", "StatusMsg", &dbv, DBVT_TCHAR)) {
		ProtoBroadcastAck((MCONTACT)hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.ptszVal);
		db_free(&dbv);
	}
	else ProtoBroadcastAck((MCONTACT)hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)NULL);
}
Пример #10
0
void CMsnProto::MsgQueue_Clear(const char* wlid, bool msg)
{
	int i;

	EnterCriticalSection(&csMsgQueue);
	if (wlid == NULL)
	{

		for(i=0; i < lsMessageQueue.getCount(); i++)
		{
			const MsgQueueEntry& E = lsMessageQueue[i];
			if (E.msgSize == 0)
			{
				MCONTACT hContact = MSN_HContactFromEmail(E.wlid);
				ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED,
					(HANDLE)E.seq, (LPARAM)Translate("Message delivery failed"));
			}
			mir_free(E.message);
			mir_free(E.wlid);
			if (E.cont) delete E.cont;
		}
		lsMessageQueue.destroy();

		msgQueueSeq = 1;
	}
	else
	{
		for(i=0; i < lsMessageQueue.getCount(); i++)
		{
			time_t ts = time(NULL);
			const MsgQueueEntry& E = lsMessageQueue[i];
			if (_stricmp(lsMessageQueue[i].wlid, wlid) == 0 && (!msg || E.msgSize == 0))
			{
				bool msgfnd = E.msgSize == 0 && E.ts < ts;
				int seq = E.seq;

				mir_free(E.message);
				mir_free(E.wlid);
				if (E.cont) delete E.cont;
				lsMessageQueue.remove(i);

				if (msgfnd)
				{
					LeaveCriticalSection(&csMsgQueue);
					MCONTACT hContact = MSN_HContactFromEmail(wlid);
					ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)seq,
						(LPARAM)Translate("Message delivery failed"));
					i = 0;
					EnterCriticalSection(&csMsgQueue);
				}
			}
		}
	}
	LeaveCriticalSection(&csMsgQueue);
}
Пример #11
0
void AvatarDownloaded(MCONTACT hContact)
{
	PROTO_AVATAR_INFORMATIONT AI = {0};
	AI.cbSize = sizeof(AI);
	AI.hContact = hContact;

	if (WeatherGetAvatarInfo(GAIF_FORCE, (LPARAM)&AI) == GAIR_SUCCESS)
		ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, &AI, 0);
	else
		ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0);
}
Пример #12
0
static void __cdecl WeatherGetAwayMsgThread(void *hContact)
{
	Sleep(100);

	DBVARIANT dbv;
	if (!db_get_ts((MCONTACT)hContact, "CList", "StatusMsg", &dbv)) {
		ProtoBroadcastAck(WEATHERPROTONAME, (MCONTACT)hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.ptszVal);
		db_free( &dbv );
	}
	else ProtoBroadcastAck(WEATHERPROTONAME, (MCONTACT)hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, 0);
}
Пример #13
0
static void __cdecl BasicSearchTimerProc(void *pszNick)
{
	PROTOSEARCHRESULT psr = { sizeof(psr) };
	psr.nick.t = (TCHAR*) pszNick;

	// broadcast the search result
	ProtoBroadcastAck(MODULENAME, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)&psr);
	ProtoBroadcastAck(MODULENAME, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0);

	// exit the search
	searchId = -1;
}
Пример #14
0
void __cdecl CAimProto::get_online_msg_thread(void* arg)
{
	Sleep(150);

	MCONTACT hContact = (MCONTACT)arg;
	DBVARIANT dbv;
	if (!db_get_ts(hContact, MOD_KEY_CL, OTH_KEY_SM, &dbv)) {
		ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.ptszVal);
		db_free(&dbv);
	}
	else ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, 0);
}
Пример #15
0
HANDLE GGPROTO::dcc7fileallow(HANDLE hTransfer, const PROTOCHAR* szPath)
{
	struct gg_dcc7 *dcc7 = (struct gg_dcc7 *) hTransfer;
	char fileName[MAX_PATH], *path = mir_t2a(szPath);
	int iFtRemoveRes;
	strncpy(fileName, path, sizeof(fileName));
	strncat(fileName, (char*)dcc7->filename, sizeof(fileName) - strlen(fileName));
	dcc7->folder = _strdup((char *) path);
	dcc7->tick = 0;
	mir_free(path);

	// Remove transfer from waiting list
	gg_EnterCriticalSection(&ft_mutex, "dcc7fileallow", 40, "ft_mutex", 1);
	iFtRemoveRes = list_remove(&transfers, dcc7, 0);
	gg_LeaveCriticalSection(&ft_mutex, "dcc7fileallow", 40, 1, "ft_mutex", 1);

	if (iFtRemoveRes == -1)
	{
		debugLogA("dcc7fileallow(): File transfer denied.");
		ProtoBroadcastAck(dcc7->contact, ACKTYPE_FILE, ACKRESULT_DENIED, dcc7, 0);
		// Free transfer
		gg_dcc7_free(dcc7);
		return 0;
	}

	// Open file for appending and check if ok
	if ((dcc7->file_fd = _open(fileName, _O_WRONLY | _O_APPEND | _O_BINARY | _O_CREAT, _S_IREAD | _S_IWRITE)) == -1)
	{
		debugLogA("dcc7fileallow(): Failed to create file \"%s\". errno=%d: %s", fileName, errno, strerror(errno));
		TCHAR error[512];
		mir_sntprintf(error, SIZEOF(error), TranslateT("Cannot create transfer file. ERROR: %d: %s (dcc7)\n%s"), errno, _tcserror(errno), szPath);
		showpopup(m_tszUserName, error, GG_POPUP_ERROR);
		gg_dcc7_reject(dcc7, GG_DCC7_REJECT_USER);
		ProtoBroadcastAck(dcc7->contact, ACKTYPE_FILE, ACKRESULT_FAILED, dcc7, 0);
		// Free transfer
		gg_dcc7_free(dcc7);
		return 0;
	}

	// Put an offset to the file
	dcc7->offset = _lseek(dcc7->file_fd, 0, SEEK_END);
	gg_dcc7_accept(dcc7, dcc7->offset);

	// Add to watches and start transfer
	gg_EnterCriticalSection(&ft_mutex, "dcc7fileallow", 41, "ft_mutex", 1);
	list_add(&watches, dcc7, 0);
	gg_LeaveCriticalSection(&ft_mutex, "dcc7fileallow", 41, 1, "ft_mutex", 1);

	debugLogA("dcc7fileallow(): Receiving file \"%s\" from %d.", dcc7->filename, dcc7->peer_uin);

	return hTransfer;
}
Пример #16
0
void ICQTransfer::ack(unsigned int result)
{
    PROTOFILETRANSFERSTATUS fts;

    if (result == ACKRESULT_DATA && GetTickCount() < lastNotify+250 && fileProgress < fileSize) return;

    fts.cbSize = sizeof(fts);
    fts.hContact = hContact;
    //fts.sending = sending;
	fts.pszFiles = files;
    fts.totalFiles = count;
    fts.currentFileNumber = current;
    fts.totalBytes = totalSize;
    fts.totalProgress = totalProgress;
    fts.szWorkingDir = path;
    fts.szCurrentFile = fileName;
    fts.currentFileSize = fileSize;
    fts.currentFileProgress = fileProgress;
    fts.currentFileTime = TimeZone_ToLocal(fileDate);
/*
    switch (session->status)
    {
    case FILE_STATUS_LISTENING: result = ACKRESULT_SENTREQUEST; break;
    case FILE_STATUS_CONNECTED: result = ACKRESULT_CONNECTED; break;
    case FILE_STATUS_CONNECTING: result = ACKRESULT_CONNECTING; break;
    case FILE_STATUS_INITIALIZING: result = ACKRESULT_INITIALISING; break;
    case FILE_STATUS_NEXT_FILE: result = ACKRESULT_NEXTFILE; break;
    case FILE_STATUS_SENDING:
    case FILE_STATUS_RECEIVING: result=ACKRESULT_DATA; break;
    }
*/
    ProtoBroadcastAck(protoName, hContact, ACKTYPE_FILE, result, this, (LPARAM)&fts);
    lastNotify = GetTickCount();

    if (result == ACKRESULT_DATA && current >= count-1 && fileProgress >= fileSize)
    {
        ProtoBroadcastAck(protoName, hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, this, 0);
        socket.closeConnection();

        unsigned int i;
        for (i=0; i<icqTransfers.size(); i++)
        {
            if (icqTransfers[i] == this)
            {
                delete icqTransfers[i];
                icqTransfers[i] = icqTransfers[icqTransfers.size() - 1];
                icqTransfers.pop_back();
                break;
            }
        }
    }
}
Пример #17
0
void TwitterProto::GetAwayMsgWorker(void *arg)
{
	MCONTACT hContact = (MCONTACT)(DWORD_PTR)arg;
	if (hContact == 0)
		return;

	DBVARIANT dbv;
	if (!db_get_ts(hContact, "CList", "StatusMsg", &dbv)) {
		ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.ptszVal);
		db_free(&dbv);
	}
	else ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_FAILED, (HANDLE)1, 0);
}
Пример #18
0
int __cdecl CMsnProto::SetStatus(int iNewStatus)
{
	if (m_iDesiredStatus == iNewStatus) return 0;

	m_iDesiredStatus = iNewStatus;
	debugLogA("PS_SETSTATUS(%d,0)", iNewStatus);

	if (m_iDesiredStatus == ID_STATUS_OFFLINE)
	{
		if (msnNsThread)
			msnNsThread->sendTerminate();
	}
	else if (!msnLoggedIn && m_iStatus == ID_STATUS_OFFLINE)
	{
		char szPassword[100];
		int ps = db_get_static(NULL, m_szModuleName, "Password", szPassword, sizeof(szPassword));
		if (ps != 0  || *szPassword == 0)
		{
			ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD);
			m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
			return 0;
		}

		if (*MyOptions.szEmail == 0)
		{
			ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID);
			m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
			return 0;
		}

		sessionList.destroy();
		dcList.destroy();

		usingGateway = false;

		int oldMode = m_iStatus;
		m_iStatus = ID_STATUS_CONNECTING;
		ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldMode, m_iStatus);

		ThreadData* newThread = new ThreadData;

		newThread->mType = SERVER_NOTIFICATION;
		newThread->mIsMainThread = true;

		newThread->startThread(&CMsnProto::MSNServerThread, this);
	}
	else
		if (m_iStatus > ID_STATUS_OFFLINE) MSN_SetServerStatus(m_iDesiredStatus);

	return 0;
}
Пример #19
0
// MsnBasicSearch - search contacts by e-mail
void __cdecl CMsnProto::MsnSearchAckThread(void* arg)
{
	const TCHAR* emailT = (TCHAR*)arg;
	T2Utf email(emailT);

	if (Lists_IsInList(LIST_FL, email)) {
		MSN_ShowPopup(emailT, TranslateT("Contact already in your contact list"), MSN_ALLOW_MSGBOX, NULL);
		ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0);
		mir_free(arg);
		return;
	}

	if (MyOptions.netId == NETID_SKYPE) MSN_SKYABSearch(email, arg);
	else {
		unsigned res = MSN_ABContactAdd(email, NULL, NETID_MSN, NULL, 1, true);
		switch (res) {
		case 0:
		case 2:
		case 3:
		{
			PROTOSEARCHRESULT psr = { 0 };
			psr.cbSize = sizeof(psr);
			psr.flags = PSR_TCHAR;
			psr.id.t = (TCHAR*)emailT;
			psr.nick.t = (TCHAR*)emailT;
			psr.email.t = (TCHAR*)emailT;

			ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, arg, (LPARAM)&psr);
			ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0);
		}
		break;

		case 1:
			if (strstr(email, "@yahoo.com") == NULL)
				ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0);
	#ifdef OBSOLETE
			else {
				msnSearchId = arg;
				MSN_FindYahooUser(email);
			}
	#endif
			break;

		default:
			ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0);
			break;
		}
	}
	mir_free(arg);
}
Пример #20
0
// MsnGetAwayMsg - reads the current status message for a user
void __cdecl CMsnProto::MsnGetAwayMsgThread(void* arg)
{
	Sleep(150);

	AwayMsgInfo *inf = (AwayMsgInfo*)arg;
	DBVARIANT dbv;
	if (!db_get_ts(inf->hContact, "CList", "StatusMsg", &dbv)) {
		ProtoBroadcastAck(inf->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)inf->id, (LPARAM)dbv.ptszVal);
		db_free(&dbv);
	}
	else ProtoBroadcastAck(inf->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)inf->id, 0);

	mir_free(inf);
}
Пример #21
0
void __cdecl CMsnProto::MsnSearchAckThread(void* arg)
{
	const TCHAR* emailT = (TCHAR*)arg;
	char *email = mir_utf8encodeT(emailT);

	if (Lists_IsInList(LIST_FL, email))
	{
		MSN_ShowPopup(emailT, TranslateT("Contact already in your contact list"), MSN_ALLOW_MSGBOX, NULL);
		ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0);
		mir_free(arg);
		return;
	}

	unsigned res = MSN_ABContactAdd(email, NULL, NETID_MSN, NULL, 1, true);
	switch(res)
	{
	case 0:
	case 2:
	case 3:
		{
			PROTOSEARCHRESULT isr = {0};
			isr.cbSize = sizeof(isr);
			isr.flags = PSR_TCHAR;
			isr.id  = (TCHAR*)emailT;
			isr.nick  = (TCHAR*)emailT;
			isr.email = (TCHAR*)emailT;

			ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, arg, (LPARAM)&isr);
			ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0);
		}
		break;

	case 1:
		if (strstr(email, "@yahoo.com") == NULL)
			ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0);
		else
		{
			msnSearchId = arg;
			MSN_FindYahooUser(email);
		}
		break;

	default:
		ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0);
		break;
	}
	mir_free(email);
	mir_free(arg);
}
Пример #22
0
void __cdecl GGPROTO::getawaymsgthread(void *hContact)
{
	DBVARIANT dbv;

	debugLogA("getawaymsgthread(): started");
	gg_sleep(100, FALSE, "getawaymsgthread", 106, 1);
	if (!db_get_s(hContact, "CList", GG_KEY_STATUSDESCR, &dbv, DBVT_TCHAR))
	{
		ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE) 1, (LPARAM) dbv.ptszVal);
		debugLog(_T("getawaymsgthread(): Reading away msg <%s>."), dbv.ptszVal);
		db_free(&dbv);
	} else {
		ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE) 1, (LPARAM) NULL);
	}
	debugLogA("getawaymsgthread(): end");
}
Пример #23
0
void CSkypeProto::ProcessUserPresence(const JSONNode &node)
{
	debugLogA("CSkypeProto::ProcessUserPresenceRes");

	std::string selfLink = node["selfLink"].as_string();
	std::string status = node["status"].as_string();
	CMStringA skypename = UrlToSkypename(selfLink.c_str());

	if (!skypename.IsEmpty())
	{
		if (IsMe(skypename))
		{
			int iNewStatus = SkypeToMirandaStatus(status.c_str());
			if (iNewStatus == ID_STATUS_OFFLINE) return;
			int old_status = m_iStatus;
			m_iDesiredStatus = iNewStatus;
			m_iStatus = iNewStatus;
			if (old_status != iNewStatus)
			{
				ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, iNewStatus);
			}
		}
		else
		{
			MCONTACT hContact = FindContact(skypename);
			if (hContact != NULL)
				SetContactStatus(hContact, SkypeToMirandaStatus(status.c_str()));
		}
	}
}
Пример #24
0
void CJabberProto::SetServerStatus(int iNewStatus)
{
	if (!m_bJabberOnline)
		return;

	// change status
	int oldStatus = m_iStatus;
	switch (iNewStatus) {
	case ID_STATUS_ONLINE:
	case ID_STATUS_NA:
	case ID_STATUS_FREECHAT:
	case ID_STATUS_INVISIBLE:
		m_iStatus = iNewStatus;
		break;
	case ID_STATUS_AWAY:
	case ID_STATUS_ONTHEPHONE:
	case ID_STATUS_OUTTOLUNCH:
		m_iStatus = ID_STATUS_AWAY;
		break;
	case ID_STATUS_DND:
	case ID_STATUS_OCCUPIED:
		m_iStatus = ID_STATUS_DND;
		break;
	default:
		return;
	}

	if (m_iStatus == oldStatus)
		return;

	// send presence update
	SendPresence(m_iStatus, true);
	ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
}
Пример #25
0
void JabberIqResultSetAuth(XmlNode *iqNode, void *userdata)
{
	struct ThreadData *info = (struct ThreadData *) userdata;
	char *type;
	int iqId;

	// RECVED: authentication result
	// ACTION: if successfully logged in, continue by requesting roster list and set my initial status
	JabberLog("<iq/> iqIdSetAuth");
	if ((type=JabberXmlGetAttrValue(iqNode, "type")) == NULL) return;

	if (!strcmp(type, "result")) {
		DBVARIANT dbv;

		if (DBGetContactSetting(NULL, jabberProtoName, "Nick", &dbv))
			DBWriteContactSettingString(NULL, jabberProtoName, "Nick", info->username);
		else
			DBFreeVariant(&dbv);
		iqId = JabberSerialNext();
		JabberIqAdd(iqId, IQ_PROC_NONE, JabberIqResultGetRoster);
		JabberSend(info->s, "<iq type='get' id='"JABBER_IQID"%d'><query xmlns='jabber:iq:roster'/></iq>", iqId);
	}
	// What to do if password error? etc...
	else if (!strcmp(type, "error")) {
		char text[128];

		JabberSend(info->s, "</s>");
		_snprintf(text, sizeof(text), "%s %[email protected]%s.", Translate("Authentication failed for"), info->username, info->server);
		MessageBox(NULL, text, Translate("Tlen Authentication"), MB_OK|MB_ICONSTOP|MB_SETFOREGROUND);
		ProtoBroadcastAck(jabberProtoName, NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD);
		jabberThreadInfo = NULL;	// To disallow auto reconnect
	}
}
Пример #26
0
int GGPROTO::dcc7filecancel(HANDLE hTransfer)
{
	struct gg_dcc7 *dcc7 = (struct gg_dcc7 *) hTransfer;

	if (dcc7->type == GG_SESSION_DCC7_SEND && dcc7->state == GG_STATE_WAITING_FOR_ACCEPT)
		gg_dcc7_abort(dcc7);

	// Remove transfer from any list
	gg_EnterCriticalSection(&ft_mutex, "dcc7filecancel", 45, "ft_mutex", 1);
	if (watches) list_remove(&watches, dcc7, 0);
	if (transfers) list_remove(&transfers, dcc7, 0);
	gg_LeaveCriticalSection(&ft_mutex, "dcc7filecancel", 45, 1, "ft_mutex", 1);

	// Send failed info
	ProtoBroadcastAck((UINT_PTR)dcc7->contact, ACKTYPE_FILE, ACKRESULT_FAILED, dcc7, 0);
	// Close file
	if (dcc7->file_fd != -1)
	{
		_close(dcc7->file_fd);
		dcc7->file_fd = -1;
	}

	debugLogA("dcc7filecancel(): Canceled file \"%s\" from/to %d.", dcc7->filename, dcc7->peer_uin);

	// Free transfer
	gg_dcc7_free(dcc7);

	return 0;
}
Пример #27
0
int GGPROTO::dccfilecancel(HANDLE hTransfer)
{
	struct gg_dcc *dcc = (struct gg_dcc *) hTransfer;

	// Remove transfer from any list
	gg_EnterCriticalSection(&ft_mutex, "dccfilecancel", 44, "ft_mutex", 1);
	if (watches) list_remove(&watches, dcc, 0);
	if (requests) list_remove(&requests, dcc, 0);
	if (transfers) list_remove(&transfers, dcc, 0);
	gg_LeaveCriticalSection(&ft_mutex, "dccfilecancel", 44, 1, "ft_mutex", 1);

	// Send failed info
	ProtoBroadcastAck((UINT_PTR)dcc->contact, ACKTYPE_FILE, ACKRESULT_FAILED, dcc, 0);
	// Close file
	if (dcc->file_fd != -1)
	{
		_close(dcc->file_fd);
		dcc->file_fd = -1;
	}

	debugLogA("dccfilecancel(): Canceled file \"%s\" from/to %d.", dcc->file_info.filename, dcc->peer_uin);

	// Free transfer
	gg_free_dcc(dcc);

	return 0;
}
Пример #28
0
// ID search	 (Threaded)
//  sID:		the ID to search for
//  searchId:	don't change
// return 0 if no error
int IDSearch(TCHAR *sID, const int searchId) 
{
	// for a normal ID search (ID != #)
	if ( _tcscmp(sID, _T("#"))) {
		WIDATALIST *Item = WIHead;

		// search every weather service using the search station ID
		while (Item != NULL) {
			IDSearchProc(sID, searchId, &Item->Data.IDSearch, Item->Data.InternalName, Item->Data.DisplayName);
			Item = Item->next;
		}
		NetlibHttpDisconnect();
	}
	// if the station ID is #, return a dummy result and quit the funciton
	else {
		// return an empty contact on "#"
		PROTOSEARCHRESULT psr = { sizeof(psr) };
		psr.flags = PSR_TCHAR;
		psr.nick = TranslateT("<Enter station name here>");	// to be entered
		psr.firstName = _T(" ");
		psr.lastName = _T("");
		psr.email = TranslateT("<Enter station ID here>");		// to be entered
		ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)searchId, (LPARAM)&psr);
	}

	return 0;
}
Пример #29
0
void TwitterProto::UpdateAvatar(HANDLE hContact,const std::string &url,bool force)
{
	DBVARIANT dbv = {0};

	if( !force && (!db_get_s(hContact,m_szModuleName,TWITTER_KEY_AV_URL,&dbv) && url == dbv.pszVal))
	{
		debugLogA( _T("***** Avatar already up-to-date: %s"), url.c_str());
	}
	else
	{
		// TODO: more defaults (configurable?)
		if(url == "http://static.twitter.com/images/default_profile_normal.png")
		{
			PROTO_AVATAR_INFORMATIONT ai = {sizeof(ai),hContact};
			
			db_set_s(hContact,m_szModuleName,TWITTER_KEY_AV_URL,url.c_str());
			ProtoBroadcastAck(hContact,ACKTYPE_AVATAR,ACKRESULT_SUCCESS,&ai,0);
		}
		else
		{
			ForkThread(&TwitterProto::UpdateAvatarWorker, new update_avatar(hContact,url));
		}
	}

	db_free(&dbv);
}
Пример #30
0
void __cdecl GGPROTO::sendackthread(void *ack)
{
	gg_sleep(100, FALSE, "sendackthread", 105, 1);
	ProtoBroadcastAck(((GG_SEQ_ACK *)ack)->hContact,
		ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE) ((GG_SEQ_ACK *)ack)->seq, 0);
	mir_free(ack);
}