Пример #1
0
void MinecraftDynmapProto::SignOffWorker(void*)
{
	ScopedLock s(signon_lock_);

	SetEvent(events_loop_event_);

	m_cookie.clear();
	m_title.clear();
	m_server.clear();
	m_timestamp.clear();

	int old_status = m_iStatus;
	m_iStatus = ID_STATUS_OFFLINE;

	Netlib_Shutdown(hEventsConnection);

	OnLeaveChat(NULL, NULL);

	delSetting("LogonTS");

	ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);

	//SetAllContactStatuses(ID_STATUS_OFFLINE);
	//ToggleStatusMenuItems(false);

	if (hConnection)
		Netlib_CloseHandle(hConnection);
	hConnection = NULL;

	if (hEventsConnection)
		Netlib_CloseHandle(hEventsConnection);
	hEventsConnection = NULL;
}
Пример #2
0
CMsnProto::~CMsnProto()
{
	MSN_FreeGroups();
	Threads_Uninit();
	AvatarQueue_Uninit();
	Lists_Uninit();
#ifdef OBSOLETE
	DestroyHookableEvent(hMSNNudge);
	P2pSessions_Uninit();
	MsgQueue_Uninit();
#endif
	CachedMsg_Uninit();

	Netlib_CloseHandle(m_hNetlibUser);
	Netlib_CloseHandle(hNetlibUserHttps);

	mir_free(mailsoundname);
	mir_free(alertsoundname);

	for (int i = 0; i < MSN_NUM_MODES; i++)
		mir_free(msnModeMsgs[i]);

	mir_free(msnLastStatusMsg);
	mir_free(msnPreviousUUX);
	mir_free(msnExternalIP);
	mir_free(msnRegistration);

	mir_free(abCacheKey);
	mir_free(sharingCacheKey);
	mir_free(storageCacheKey);
	mir_free(m_DisplayNameCache);

	FreeAuthTokens();
}
Пример #3
0
void TlenWsUninit(TlenProtocol *proto)
{
	if (proto->m_hNetlibUser != NULL) Netlib_CloseHandle(proto->m_hNetlibUser);
	if (proto->hFileNetlibUser != NULL) Netlib_CloseHandle(proto->hFileNetlibUser);
	proto->m_hNetlibUser = NULL;
	proto->hFileNetlibUser = NULL;
}
Пример #4
0
bool Omegle_client::stop( )
{
	if ( parent->isOffline())
		return true;

	handle_entry( "stop" );

	std::string data = "id=" + this->chat_id_;

	http::response resp = flap( OMEGLE_REQUEST_STOP, &data );

	if (hConnection)
		Netlib_CloseHandle(hConnection);
	hConnection = NULL;

	if (hEventsConnection)
		Netlib_CloseHandle(hEventsConnection);
	hEventsConnection = NULL;

	if (resp.data == "win") {
		return handle_success( "stop" );
	} else {
		return handle_error( "stop" );
	}

/*	switch ( resp.code )
	{
	case HTTP_CODE_OK:
	case HTTP_CODE_FOUND:

	default:
		
	}*/
}
Пример #5
0
ThreadData::~ThreadData()
{
	if ( s != NULL ) {
		MSN_DebugLog( "Closing connection handle %08X", s );
		Netlib_CloseHandle( s );
	}

	if ( mIncomingBoundPort != NULL ) {
		Netlib_CloseHandle( mIncomingBoundPort );
	}

	if ( mMsnFtp != NULL ) {
		delete mMsnFtp;
		mMsnFtp = NULL;
	}

	if ( hWaitEvent != INVALID_HANDLE_VALUE )
		CloseHandle( hWaitEvent );

	p2p_clearDormantSessions();

	free( mJoinedContacts );

	while (mFirstQueueItem != NULL)
	{
		TQueueItem* QI = mFirstQueueItem;
		mFirstQueueItem = mFirstQueueItem->next;
		free(QI);
}	}
Пример #6
0
void JabberFileServerConnection(JABBER_SOCKET hConnection, DWORD /*dwRemoteIP*/, void* extra)
{
	CJabberProto *ppro = (CJabberProto*)extra;

	NETLIBCONNINFO connInfo = { sizeof(connInfo) };
	CallService(MS_NETLIB_GETCONNECTIONINFO, (WPARAM)hConnection, (LPARAM)&connInfo);

	TCHAR szPort[10];
	mir_sntprintf(szPort, _countof(szPort), _T("%d"), connInfo.wPort);
	ppro->debugLogA("File server incoming connection accepted: %s", connInfo.szIpPort);

	JABBER_LIST_ITEM *item = ppro->ListGetItemPtr(LIST_FILE, szPort);
	if (item == NULL) {
		ppro->debugLogA("No file is currently served, file server connection closed.");
		Netlib_CloseHandle(hConnection);
		return;
	}

	filetransfer *ft = item->ft;
	JABBER_SOCKET slisten = ft->s;
	ft->s = hConnection;
	ppro->debugLogA("Set ft->s to %d (saving %d)", hConnection, slisten);

	char* buffer = (char*)mir_alloc(JABBER_NETWORK_BUFFER_SIZE + 1);
	if (buffer == NULL) {
		ppro->debugLogA("Cannot allocate network buffer, file server connection closed.");
		Netlib_CloseHandle(hConnection);
		ft->state = FT_ERROR;
		if (ft->hFileEvent != NULL)
			SetEvent(ft->hFileEvent);
		return;
	}

	ppro->debugLogA("Entering recv loop for this file connection... (ft->s is hConnection)");
	int datalen = 0;
	while (ft->state != FT_DONE && ft->state != FT_ERROR) {
		int recvResult, bytesParsed;

		recvResult = Netlib_Recv(hConnection, buffer + datalen, JABBER_NETWORK_BUFFER_SIZE - datalen, 0);
		if (recvResult <= 0)
			break;
		datalen += recvResult;

		buffer[datalen] = '\0';
		ppro->debugLogA("RECV:%s", buffer);

		bytesParsed = ppro->FileSendParse(hConnection, ft, buffer, datalen);
		if (bytesParsed < datalen)
			memmove(buffer, buffer + bytesParsed, datalen - bytesParsed);
		datalen -= bytesParsed;
	}

	ppro->debugLogA("Closing connection for this file transfer... (ft->s is now hBind)");
	Netlib_CloseHandle(hConnection);
	ft->s = slisten;
	ppro->debugLogA("ft->s is restored to %d", ft->s);
	if (ft->hFileEvent != NULL)
		SetEvent(ft->hFileEvent);
	mir_free(buffer);
}
Пример #7
0
CMsnProto::~CMsnProto()
{
	MsnRemoveMainMenus();

	DestroyHookableEvent(hMSNNudge);

	MSN_FreeGroups();
	Threads_Uninit();
	MsgQueue_Uninit();
	Lists_Uninit();
	P2pSessions_Uninit();
	CachedMsg_Uninit();

	Netlib_CloseHandle(hNetlibUser);
	Netlib_CloseHandle(hNetlibUserHttps);

	mir_free(mailsoundname);
	mir_free(alertsoundname);
	mir_free(m_tszUserName);
	mir_free(m_szModuleName);
	mir_free(m_szProtoName);

	for (int i=0; i < MSN_NUM_MODES; i++)
		mir_free(msnModeMsgs[i]);

	mir_free(msnLastStatusMsg);
	mir_free(msnPreviousUUX);
	mir_free(msnExternalIP);

	mir_free(abCacheKey);
	mir_free(sharingCacheKey);
	mir_free(storageCacheKey);

	FreeAuthTokens();
}
Пример #8
0
void JabberByteSendConnection( HANDLE hConn, DWORD /*dwRemoteIP*/, void* extra )
{
	CJabberProto* ppro = ( CJabberProto* )extra;
	TCHAR szPort[8];
	JABBER_BYTE_TRANSFER *jbt;
	int recvResult, bytesParsed;
	HANDLE hListen;
	JABBER_LIST_ITEM *item;
	char* buffer;
	int datalen;

	NETLIBCONNINFO connInfo = { sizeof(connInfo) }; 
	CallService(MS_NETLIB_GETCONNECTIONINFO, (WPARAM)hConn, (LPARAM)&connInfo);

	mir_sntprintf( szPort, SIZEOF( szPort ), _T("%u"), connInfo.wPort );
	ppro->Log( "bytestream_send_connection incoming connection accepted: %s", connInfo.szIpPort );

	if (( item = ppro->ListGetItemPtr( LIST_BYTE, szPort )) == NULL ) {
		ppro->Log( "No bytestream session is currently active, connection closed." );
		Netlib_CloseHandle( hConn );
		return;
	}

	jbt = item->jbt;

	if (( buffer = ( char* )mir_alloc( JABBER_NETWORK_BUFFER_SIZE )) == NULL ) {
		ppro->Log( "bytestream_send cannot allocate network buffer, connection closed." );
		jbt->state = JBT_ERROR;
		Netlib_CloseHandle( hConn );
		if ( jbt->hEvent != NULL ) SetEvent( jbt->hEvent );
		return;
	}

	hListen = jbt->hConn;
	jbt->hConn = hConn;
	jbt->state = JBT_INIT;
	datalen = 0;
	while ( jbt->state!=JBT_DONE && jbt->state!=JBT_ERROR ) {
		recvResult = Netlib_Recv( hConn, buffer+datalen, JABBER_NETWORK_BUFFER_SIZE-datalen, 0 );
		if ( recvResult <= 0 )
			break;

		datalen += recvResult;
		bytesParsed = ppro->ByteSendParse( hConn, jbt, buffer, datalen );
		if ( bytesParsed < datalen )
			memmove( buffer, buffer+bytesParsed, datalen-bytesParsed );
		datalen -= bytesParsed;
	}

	if ( jbt->hConn )
		Netlib_CloseHandle( jbt->hConn );

	ppro->Log( "bytestream_send_connection closing connection" );
	jbt->hConn = hListen;
	mir_free( buffer );

	if ( jbt->hEvent != NULL )
		SetEvent( jbt->hEvent );
}
Пример #9
0
void __cdecl CAimProto::aim_avatar_negotiation(void*)
{
	HANDLE hServerPacketRecver = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)m_hAvatarConn, 2048 * 8);

	NETLIBPACKETRECVER packetRecv = { 0 };
	packetRecv.cbSize = sizeof(packetRecv);
	packetRecv.dwTimeout = 300000;//5 minutes connected
	for (;;) {
		int recvResult = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM)hServerPacketRecver, (LPARAM)& packetRecv);
		if (recvResult == 0)
			break;

		if (recvResult == SOCKET_ERROR)
			break;

		if (recvResult > 0) {
			unsigned short flap_length = 0;
			for (; packetRecv.bytesUsed < packetRecv.bytesAvailable; packetRecv.bytesUsed = flap_length) {
				if (!packetRecv.buffer)
					break;

				FLAP flap((char*)&packetRecv.buffer[packetRecv.bytesUsed], packetRecv.bytesAvailable - packetRecv.bytesUsed);
				if (!flap.len())
					break;

				flap_length += FLAP_SIZE + flap.len();
				if (flap.cmp(0x01)) {
					aim_send_cookie(m_hAvatarConn, m_avatar_seqno, AVATAR_COOKIE_LENGTH, AVATAR_COOKIE); // cookie challenge
					mir_free(AVATAR_COOKIE);
					AVATAR_COOKIE = NULL;
					AVATAR_COOKIE_LENGTH = 0;
				}
				else if (flap.cmp(0x02)) {
					SNAC snac(flap.val(), flap.snaclen());
					if (snac.cmp(0x0001)) {
						snac_supported_families(snac, m_hAvatarConn, m_avatar_seqno);
						snac_supported_family_versions(snac, m_hAvatarConn, m_avatar_seqno);
						snac_avatar_rate_limitations(snac, m_hAvatarConn, m_avatar_seqno);
						snac_error(snac);
					}
					if (snac.cmp(0x0010)) {
						snac_retrieve_avatar(snac);
						snac_upload_reply_avatar(snac);
					}
				}
				else if (flap.cmp(0x04))
					goto exit;
			}
		}
	}

exit:
	Netlib_CloseHandle(hServerPacketRecver);
	Netlib_CloseHandle(m_hAvatarConn);
	m_hAvatarConn = NULL;
	ResetEvent(m_hAvatarEvent);
	debugLogA("Avatar Server Connection has ended");
}
Пример #10
0
void Stop()
{
    if(ghPacketReciever)
        Netlib_CloseHandle(ghPacketReciever);
    if(ghConnection)
        Netlib_CloseHandle(ghConnection);
    if(ghNetlibUser && (ghNetlibUser != INVALID_HANDLE_VALUE))
        CallService(MS_NETLIB_SHUTDOWN,(WPARAM)ghNetlibUser,0);
}
Пример #11
0
TwitterProto::~TwitterProto()
{
	twit_.Disconnect();

	if (m_hNetlibUser)
		Netlib_CloseHandle(m_hNetlibUser);
	if (hAvatarNetlib_)
		Netlib_CloseHandle(hAvatarNetlib_);
}
Пример #12
0
void ReStart(void *param)
{
    if(ghPacketReciever)
        Netlib_CloseHandle(ghPacketReciever);
    if(ghConnection)
        Netlib_CloseHandle(ghConnection);
    Sleep(500);
    mir_forkthread(&Start, 0);
}
Пример #13
0
ThreadData::~ThreadData()
{
	if (s != NULL) {
		proto->debugLogA("Closing connection handle %08X", s);
		Netlib_CloseHandle(s);
	}

	if (mIncomingBoundPort != NULL) {
		Netlib_CloseHandle(mIncomingBoundPort);
	}

	if (mMsnFtp != NULL) {
		delete mMsnFtp;
		mMsnFtp = NULL;
	}

	if (hWaitEvent != INVALID_HANDLE_VALUE)
		CloseHandle(hWaitEvent);

	if (mTimerId != 0)
		KillTimer(NULL, mTimerId);

#ifdef OBSOLETE
	if (mType == SERVER_SWITCHBOARD) {
		for (int i = 0; i < mJoinedContactsWLID.getCount(); ++i) {
			const char* wlid = mJoinedContactsWLID[i];
			MCONTACT hContact = proto->MSN_HContactFromEmail(wlid);
			int temp_status = proto->getWord(hContact, "Status", ID_STATUS_OFFLINE);
			if (temp_status == ID_STATUS_INVISIBLE && proto->MSN_GetThreadByContact(wlid) == NULL)
				proto->setWord(hContact, "Status", ID_STATUS_OFFLINE);
		}
	}
#endif

	mJoinedContactsWLID.destroy();
	mJoinedIdentContactsWLID.destroy();

	mir_free(mInitialContactWLID); mInitialContactWLID = NULL;

#ifdef OBSOLETE
	const char* wlid = NEWSTR_ALLOCA(mInitialContactWLID);

	if (proto && mType == SERVER_P2P_DIRECT)
		proto->p2p_clearDormantSessions();

	if (wlid != NULL && mType == SERVER_SWITCHBOARD &&
		proto->MSN_GetThreadByContact(wlid) == NULL &&
		proto->MSN_GetUnconnectedThread(wlid) == NULL) {
		proto->MsgQueue_Clear(wlid, true);
	}
#endif

	mir_free(mData);
}
Пример #14
0
FacebookProto::~FacebookProto()
{
	// Uninit popup classes
	for (std::vector<HANDLE>::size_type i = 0; i < popupClasses.size(); i++)
		Popup_UnregisterClass(popupClasses[i]);
	popupClasses.clear();

	Netlib_CloseHandle(m_hNetlibUser);

	WaitForSingleObject(signon_lock_, IGNORE);
	WaitForSingleObject(avatar_lock_, IGNORE);
	WaitForSingleObject(log_lock_, IGNORE);
	WaitForSingleObject(facy.buddies_lock_, IGNORE);
	WaitForSingleObject(facy.send_message_lock_, IGNORE);
	WaitForSingleObject(facy.notifications_lock_, IGNORE);
	WaitForSingleObject(facy.cookies_lock_, IGNORE);

	CloseHandle(signon_lock_);
	CloseHandle(avatar_lock_);
	CloseHandle(log_lock_);
	CloseHandle(update_loop_lock_);
	CloseHandle(facy.buddies_lock_);
	CloseHandle(facy.send_message_lock_);
	CloseHandle(facy.fcb_conn_lock_);
	CloseHandle(facy.notifications_lock_);
	CloseHandle(facy.cookies_lock_);
}
Пример #15
0
bool facebook_client::logout()
{
	if (parent->getByte(FACEBOOK_KEY_DISABLE_LOGOUT, 0))
		return true;

	handle_entry("logout");

	std::string data = "fb_dtsg=" + (!this->dtsg_.empty() ? this->dtsg_ : "0");
	data += "&ref=mb&h=" + this->logout_hash_;

	http::response resp = flap(REQUEST_LOGOUT, &data);

	if (hFcbCon)
		Netlib_CloseHandle(hFcbCon);
	hFcbCon = NULL;

	// Process result
	username_ = password_ = self_.user_id = "";

	switch (resp.code)
	{
	case HTTP_CODE_OK:
	case HTTP_CODE_FOUND:
		return handle_success("logout");

	default:
		return false; // Logout not finished properly, but..okay, who cares :P
	}
}
Пример #16
0
bool facebook_client::logout( )
{
	if ( DBGetContactSettingByte(NULL, parent->m_szModuleName, FACEBOOK_KEY_DISABLE_LOGOUT, 0) )
		return true;

	handle_entry( "logout" );

	std::string data = "post_form_id=";
	data += ( this->post_form_id_.length( ) ) ? this->post_form_id_ : "0";
	data += "&fb_dtsg=";
	data += ( this->dtsg_.length( ) ) ? this->dtsg_ : "0";
	data += "&ref=mb&h=";
	data += this->logout_hash_;

	http::response resp = flap( FACEBOOK_REQUEST_LOGOUT, &data );

	if (hFcbCon)
		Netlib_CloseHandle(hFcbCon);
	hFcbCon = NULL;

	// Process result
	username_ = password_ = self_.user_id = "";

	switch ( resp.code )
	{
	case HTTP_CODE_OK:
	case HTTP_CODE_FOUND:
		return handle_success( "logout" );

	default:
		return false; // Logout not finished properly, but..okay, who cares :P
	}
}
Пример #17
0
void aim_direct_connection_initiated(HANDLE hNewConnection, DWORD dwRemoteIP, CAimProto* ppro)//for receiving stuff via dc
{
	 file_transfer *ft;

	char cip[20];
	ppro->LOG("Buddy connected from IP: %s", long_ip_to_char_ip(dwRemoteIP, cip));

	//okay someone connected to us or we initiated the connection- we need to figure out who they are and if they belong
	for (int i=21; --i; )
	{
		ft = ppro->ft_list.find_by_ip(dwRemoteIP);

		if (ft == NULL) ft = ppro->ft_list.find_suitable();
		if (ft || Miranda_Terminated()) break;
		Sleep(100);
	}

	if (ft)
	{
		ft->hConn = hNewConnection;
		ppro->aim_dc_helper(ft);
	}
	else 
		Netlib_CloseHandle(hNewConnection);
}
Пример #18
0
void FacebookProto::StickerAsSmiley(std::string sticker, const std::string &url, MCONTACT hContact)
{
	std::string b64 = ptrA(mir_base64_encode((PBYTE)sticker.c_str(), (unsigned)sticker.length()));
	b64 = utils::url::encode(b64);

	std::tstring filename = GetAvatarFolder() + _T("\\stickers\\");
	ptrT dir(mir_tstrdup(filename.c_str()));

	filename += (TCHAR*)_A2T(b64.c_str());
	filename += _T(".png");

	// Check if we have this sticker already and download it it not
	if (GetFileAttributes(filename.c_str()) == INVALID_FILE_ATTRIBUTES) {
		HANDLE nlc = NULL;
		facy.save_url(url, filename, nlc);
		Netlib_CloseHandle(nlc);
	}

	SMADD_CONT cont;
	cont.cbSize = sizeof(SMADD_CONT);
	cont.hContact = hContact;
	cont.type = 0;
	cont.path = dir;

	CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, (LPARAM)&cont);
}
Пример #19
0
void __cdecl SessionClose(mwSession* session)
{
	CSametimeProto* proto = (CSametimeProto*)mwSession_getProperty(session, "PROTO_STRUCT_PTR");
	proto->debugLog(_T("SessionClose()  server_connection=[%d]"), proto->server_connection);
	Netlib_CloseHandle(proto->server_connection);
	proto->server_connection = 0;
}
Пример #20
0
void __cdecl SmileyDownloadThread(void*)
{
	bool needext = false;
	HANDLE hHttpDwnl = NULL;
	WaitForSingleObject(g_hDlMutex, 3000);
	while (!Miranda_Terminated() && dlQueue.getCount()) {
		ReleaseMutex(g_hDlMutex);
		if (_taccess(dlQueue[0].fname.c_str(), 0) != 0) {
			InternetDownloadFile(T2A_SM(dlQueue[0].url.c_str()), T2A_SM(dlQueue[0].fname.c_str()), hHttpDwnl);
			WaitForSingleObject(g_hDlMutex, 3000);

			CMString fname(dlQueue[0].fname);
			if (dlQueue[0].needext) { fname += GetImageExt(fname); needext = true; }
			_trename(dlQueue[0].fname.c_str(), fname.c_str());
		}
		else WaitForSingleObject(g_hDlMutex, 3000);

		dlQueue.remove(0);
	}
	dlQueue.destroy();
	if (hHttpDwnl) Netlib_CloseHandle(hHttpDwnl);
	threadRunning = false;
	ReleaseMutex(g_hDlMutex);

	if (!Miranda_Terminated()) {
		if (needext)
			CallServiceSync(MS_SMILEYADD_RELOAD, 0, 0);
		else
			NotifyEventHooks(hEvent1, 0, 0);
	}
}
Пример #21
0
extern "C" int __declspec(dllexport) Unload(void) 
{	
	UnhookEvent(hModulesLoaded);
	UnhookEvent(hPrebuildContactMenu);
	UnhookEvent(hOptionsInit);
	if(hWindowEvent != NULL)
		UnhookEvent(hWindowEvent);

	DestroyServiceFunction(hServiceContactMenu);
	Netlib_CloseHandle(g_hNetlibUser);
	if(hTabsrmmButtonPressed != NULL)
		UnhookEvent(hTabsrmmButtonPressed);

	for(int i=0; i < PasteToWeb::pages; ++i)
		if(pasteToWebs[i] != NULL) {
			delete pasteToWebs[i];
			pasteToWebs[i] = NULL;
		}

	if(Options::instance != NULL) {
		delete Options::instance;
		Options::instance = NULL;
	}

	delete contactWindows;
	return 0;
}
Пример #22
0
extern "C" int __declspec(dllexport) Unload(void)
{
   ChangeContactStatus(0);

   KillTimer(NULL, timerId);
   KillTimer(NULL, Countdown);

   db_set_b(NULL, MODULENAME, HAS_CRASHED_KEY, 0);
   SavewinSettings();
   if (hRichEd)
		FreeLibrary(hRichEd);

	if (hNetlibUser) {
		Netlib_CloseHandle(hNetlibUser);
		hNetlibUser = NULL;
	}
	
	if (hHookDisplayDataAlert)
		DestroyHookableEvent(hHookDisplayDataAlert);
	if (hHookAlertPopup)
		DestroyHookableEvent(hHookAlertPopup);
	if (hHookAlertWPopup)
		DestroyHookableEvent(hHookAlertWPopup);
	
	if (h_font != NULL)
		DeleteObject(h_font);
	if (hMenu)
		DestroyMenu(hMenu);    
	WindowList_Destroy(hWindowList);
	return 0;
}
Пример #23
0
void __cdecl CAimProto::aim_dc_helper(void* param) //only called when we are initiating a direct connection with someone else
{
	file_transfer *ft = (file_transfer*)param;	

	sendBroadcast(ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTED, ft, 0);

	NETLIBPACKETRECVER packetRecv = {0};
	packetRecv.cbSize = sizeof(packetRecv);
	packetRecv.dwTimeout = 350000;

	HANDLE hServerPacketRecver = (HANDLE) CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)ft->hConn, 2048 * 4);

	int result;
	if (ft->sending)//we are sending
		result = sending_file(ft, hServerPacketRecver, packetRecv);
	else 
		result = receiving_file(ft, hServerPacketRecver, packetRecv);

	Netlib_CloseHandle(hServerPacketRecver);
	Netlib_CloseHandle(ft->hConn);
	ft->hConn = NULL;

	if (result == 0)
	{
		sendBroadcast(ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0);
	}
	else
	{
		if (!ft->requester && result == 1 && !Miranda_Terminated())
		{
			ft->accepted = false;
			HANDLE hConn = aim_peer_connect(AIM_PROXY_SERVER, get_default_port());
			if (hConn) 
			{
				LOG("Connected to proxy ip because we want to use a proxy for the file transfer.");
				ft->requester = true;
				ft->hConn = hConn;
				ForkThread(&CAimProto::aim_proxy_helper, ft);
				return;
			}
		}
		aim_file_ad(hServerConn, seqno, ft->sn, ft->icbm_cookie, true, 0);
		sendBroadcast(ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
	}

	ft_list.remove_by_ft(ft);
}
Пример #24
0
void NetlibHttpDisconnect(void)
{
	if (hNetlibHttp) {
		HANDLE hConn = hNetlibHttp;
		hNetlibHttp = NULL;
		Netlib_CloseHandle(hConn);
	}
}
Пример #25
0
extern "C" int __declspec(dllexport) Unload(void)
{
	LOG(("Unload"));

	YmsgrLinksUninit();
	Netlib_CloseHandle(g_hNetlibUser);
	return 0;
}
Пример #26
0
void file_transfer::stop_listen(void)
{
	if (hDirectBoundPort) {
		Netlib_CloseHandle(hDirectBoundPort);
		hDirectBoundPort = NULL;
		local_port = 0;
	}
}
Пример #27
0
int CSteamProto::OnPreShutdown(WPARAM, LPARAM)
{
	//SetStatus(ID_STATUS_OFFLINE);

	Netlib_CloseHandle(this->m_hNetlibUser);
	this->m_hNetlibUser = NULL;

	return 0;
}
Пример #28
0
static void ApplyDownloads(void *param)
{
	HWND hDlg = (HWND)param;

	//////////////////////////////////////////////////////////////////////////////////////
	// if we need to escalate priviledges, launch a atub

	if (!PrepareEscalation()) {
		PostMessage(hDlg, WM_CLOSE, 0, 0);
		return;
	}

	//////////////////////////////////////////////////////////////////////////////////////
	// ok, let's unpack all zips

	AutoHandle pipe(hPipe);
	HWND hwndList = GetDlgItem(hDlg, IDC_LIST_UPDATES);
	OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
	//create needed folders after escalating priviledges. Folders creates when we actually install updates
	TCHAR tszFileTemp[MAX_PATH], tszFileBack[MAX_PATH];

	mir_sntprintf(tszFileBack, _countof(tszFileBack), _T("%s\\Backups"), tszRoot);
	SafeCreateDirectory(tszFileBack);

	mir_sntprintf(tszFileTemp, _countof(tszFileTemp), _T("%s\\Temp"), tszRoot);
	SafeCreateDirectory(tszFileTemp);

	VARST tszMirandaPath(_T("%miranda_path%"));

	HANDLE nlc = NULL;
	for (int i=0; i < todo.getCount(); ++i) {
		ListView_EnsureVisible(hwndList, i, FALSE);
		if (todo[i].bEnabled) {
			// download update
			ListView_SetItemText(hwndList, i, 1, TranslateT("Downloading..."));

			if (DownloadFile(&todo[i].File, nlc)) {
				ListView_SetItemText(hwndList, i, 1, TranslateT("Succeeded."));
				if (unzip(todo[i].File.tszDiskPath, tszMirandaPath, tszFileBack,false))
					SafeDeleteFile(todo[i].File.tszDiskPath);  // remove .zip after successful update
			}
			else
				ListView_SetItemText(hwndList, i, 1, TranslateT("Failed!"));
		}
		else
			ListView_SetItemText(hwndList, i, 1, TranslateT("Skipped."));
	}
	Netlib_CloseHandle(nlc);

	ShowPopup(TranslateT("Plugin Updater"), TranslateT("Download complete"), POPUP_TYPE_INFO);

	int rc = MessageBox(hDlg, TranslateT("Download complete. Do you want to go to plugins option page?"), TranslateT("Plugin Updater"), MB_YESNO | MB_ICONQUESTION);
	if (rc == IDYES)
		CallFunctionAsync(OpenPluginOptions, 0);

	PostMessage(hDlg, WM_CLOSE, 0, 0);
}
Пример #29
0
static void TlenPsPostThread(void *ptr) {
	TLENPSREQUESTTHREADDATA *data = (TLENPSREQUESTTHREADDATA *)ptr;
	TlenProtocol *proto = data->proto;
	TLEN_LIST_ITEM *item = data->item;
	HANDLE socket = TlenWsConnect(proto, "ps.tlen.pl", 443);
	BOOL bSent = FALSE;
	if (socket != NULL) {
		char header[512];
		DWORD ret;
		item->ft->s = socket;
		item->ft->hFileEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
		mir_snprintf(header, sizeof(header), "<pic auth='%s' t='p' to='%s' size='%d' idt='%s'/>", proto->threadData->username, item->ft->jid, item->ft->fileTotalSize, item->jid);
		TlenWsSend(proto, socket, header, (int)strlen(header));
		ret = WaitForSingleObject(item->ft->hFileEvent, 1000 * 60 * 5);
		if (ret == WAIT_OBJECT_0) {
			FILE *fp = fopen( item->ft->files[0], "rb" );
			if (fp) {
				int i;
				char header[512];
				char fileBuffer[2048];
				mir_snprintf(header, sizeof(header), "<pic st='%s' idt='%s'/>", item->ft->iqId, item->jid);
				TlenWsSend(proto, socket, header, (int)strlen(header));
				proto->debugLogA("Sending picture data...");
				for (i = item->ft->filesSize[0]; i > 0; ) {
					int toread = min(2048, i);
					int readcount = (int)fread(fileBuffer, (size_t)1, (size_t)toread, fp);
					i -= readcount;
					if (readcount > 0) {
						TlenWsSend(proto, socket, fileBuffer, readcount);
					}
					if (toread != readcount) {
						break;
					}
				}
				fclose(fp);
				SleepEx(3000, TRUE);
				bSent = TRUE;
			} else {
			  /* picture not found */
			}
		} else {
			/* 5 minutes passed */
		}
		Netlib_CloseHandle(socket);
		if (bSent) {
			TlenSend(proto, "<message to='%s' idt='%s' rt='%s' pid='1001' type='pic' />", item->ft->jid, item->jid, item->ft->id2);
			LogPictureMessage(proto, item->ft->jid, item->ft->files[0], TRUE);
		}
		TlenP2PFreeFileTransfer(item->ft);
		TlenListRemove(proto, LIST_PICTURE, item->jid);
	} else {
		/* cannot connect to ps server */
	}
	mir_free(data);
}
Пример #30
0
int OnShutdown(WPARAM wParam, LPARAM lParam) {

	//DeinitUtils();
	DestroyPluginServices();

	DeinitConferenceMenu();
	DeinitSessionMenu();

	Netlib_CloseHandle(hNetlibUser);

	return 0;
}