示例#1
0
/*static*/ void ContactDoubleclicked(WPARAM wParam, LPARAM lParam)
{
	DBVARIANT dbv;
	char *szProto;
	HACCOUNT ActualAccount;

	szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0);
	if(szProto != NULL && strcmp(szProto, ProtoName)==0)
	{
		if(!DBGetContactSetting((HANDLE) wParam,ProtoName,"Id",&dbv)) 
		{
			ActualAccount=(HACCOUNT) CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)dbv.pszVal);
			if(ActualAccount != NULL)
			{
				#ifdef DEBUG_SYNCHRO
				DebugLog(SynchroFile,"Service_ContactDoubleclicked:ActualAccountSO-read wait\n");
				#endif
				if(WAIT_OBJECT_0==WaitToReadFcn(ActualAccount->AccountAccessSO))
				{
					#ifdef DEBUG_SYNCHRO
					DebugLog(SynchroFile,"Service_ContactDoubleclicked:ActualAccountSO-read enter\n");
					#endif
					YAMN_MAILBROWSERPARAM Param={(HANDLE)0,ActualAccount,ActualAccount->NewMailN.Flags,ActualAccount->NoNewMailN.Flags,0};

					Param.nnflags=Param.nnflags | YAMN_ACC_MSG;			//show mails in account even no new mail in account
					Param.nnflags=Param.nnflags & ~YAMN_ACC_POP;

					Param.nflags=Param.nflags | YAMN_ACC_MSG;			//show mails in account even no new mail in account
					Param.nflags=Param.nflags & ~YAMN_ACC_POP;

					RunMailBrowserSvc((WPARAM)&Param,(LPARAM)YAMN_MAILBROWSERVERSION);
					
					#ifdef DEBUG_SYNCHRO
					DebugLog(SynchroFile,"Service_ContactDoubleclicked:ActualAccountSO-read done\n");
					#endif
					ReadDoneFcn(ActualAccount->AccountAccessSO);
				}
				#ifdef DEBUG_SYNCHRO
				else
					DebugLog(SynchroFile,"Service_ContactDoubleclicked:ActualAccountSO-read enter failed\n");
				#endif
				
			}
			DBFreeVariant(&dbv);
		}

	}
}
示例#2
0
INT_PTR ForceCheckSvc(WPARAM, LPARAM)
{
	PYAMN_PROTOPLUGINQUEUE ActualPlugin;
	HACCOUNT ActualAccount;
	HANDLE ThreadRunningEV;
	DWORD tid;

	//we use event to signal, that running thread has all needed stack parameters copied
	if (NULL==(ThreadRunningEV=CreateEvent(NULL, FALSE, FALSE, NULL)))
		return 0;
	//if we want to close miranda, we get event and do not run pop3 checking anymore
	if (WAIT_OBJECT_0==WaitForSingleObject(ExitEV, 0))
		return 0;
	EnterCriticalSection(&PluginRegCS);
	for (ActualPlugin=FirstProtoPlugin;ActualPlugin != NULL;ActualPlugin=ActualPlugin->Next)
	{
		#ifdef DEBUG_SYNCHRO
		DebugLog(SynchroFile, "ForceCheck:AccountBrowserSO-read wait\n");
		#endif
		SWMRGWaitToRead(ActualPlugin->Plugin->AccountBrowserSO, INFINITE);
		#ifdef DEBUG_SYNCHRO
		DebugLog(SynchroFile, "ForceCheck:AccountBrowserSO-read enter\n");
		#endif
		for (ActualAccount=ActualPlugin->Plugin->FirstAccount;ActualAccount != NULL;ActualAccount=ActualAccount->Next)
		{
			if (ActualAccount->Plugin->Fcn==NULL)		//account not inited
				continue;
			#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile, "ForceCheck:ActualAccountSO-read wait\n");
			#endif
			if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO))
			{
				#ifdef DEBUG_SYNCHRO
				DebugLog(SynchroFile, "ForceCheck:ActualAccountSO-read wait failed\n");
				#endif
				continue;
			}
			#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile, "ForceCheck:ActualAccountSO-read enter\n");
			#endif
			if ((ActualAccount->Flags & YAMN_ACC_ENA) && (ActualAccount->StatusFlags & YAMN_ACC_FORCE))			//account cannot be forced to check
			{
				if (ActualAccount->Plugin->Fcn->ForceCheckFcnPtr==NULL)
				{
					ReadDoneFcn(ActualAccount->AccountAccessSO);
					continue;
				}
				struct CheckParam ParamToPlugin={YAMN_CHECKVERSION, ThreadRunningEV, ActualAccount, YAMN_FORCECHECK, (void *)0, NULL};

				if (NULL==CreateThread(NULL, 0, (YAMN_STANDARDFCN)ActualAccount->Plugin->Fcn->ForceCheckFcnPtr, &ParamToPlugin, 0, &tid))
				{
					ReadDoneFcn(ActualAccount->AccountAccessSO);
					continue;
				}
				else
					WaitForSingleObject(ThreadRunningEV, INFINITE);
			}
			ReadDoneFcn(ActualAccount->AccountAccessSO);
		}
#ifdef DEBUG_SYNCHRO
		DebugLog(SynchroFile, "ForceCheck:AccountBrowserSO-read done\n");
#endif
		SWMRGDoneReading(ActualPlugin->Plugin->AccountBrowserSO);
	}
	LeaveCriticalSection(&PluginRegCS);
	CloseHandle(ThreadRunningEV);

	if (hTTButton) CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hTTButton, 0);
	return 1;
}
示例#3
0
static INT_PTR PerformAccountWriting(HYAMNPROTOPLUGIN Plugin,HANDLE File)
{
	DWORD WrittenBytes,Stat;
	HACCOUNT ActualAccount;
	DWORD Ver=YAMN_ACCOUNTFILEVERSION;
	BOOL Writed=FALSE;
	DWORD ReturnValue=0,EnterCode;
	
#ifdef DEBUG_SYNCHRO
	DebugLog(SynchroFile,"WriteAccountsToFile:AccountBrowserSO-read wait\n");
#endif
	SWMRGWaitToRead(Plugin->AccountBrowserSO,INFINITE);
#ifdef DEBUG_SYNCHRO
	DebugLog(SynchroFile,"WriteAccountsToFile:AccountBrowserSO-read enter\n");
#endif
	try
	{
		for (ActualAccount=Plugin->FirstAccount;ActualAccount != NULL;ActualAccount=ActualAccount->Next)
		{
#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read wait\n");
#endif
			EnterCode=WaitToReadFcn(ActualAccount->AccountAccessSO);
			if (EnterCode==WAIT_FINISH)		//account is about to delete
			{
#ifdef DEBUG_SYNCHRO
				DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read wait failed\n");
#endif
				ActualAccount=ActualAccount->Next;
				continue;
			}
			if (EnterCode==WAIT_FAILED)		//account is deleted
				break;
#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read enter\n");
#endif
			if ((ActualAccount->Name==NULL) || (*ActualAccount->Name==(TCHAR)0))
			{
#ifdef DEBUG_SYNCHRO
				DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read done\n");
#endif
				ReadDoneFcn(ActualAccount->AccountAccessSO);
				continue;
			}

			if (!Writed && !WriteFile(File,&Ver,sizeof(Ver),&WrittenBytes,NULL))
				throw (DWORD)EACC_SYSTEM;
			Writed=TRUE;

			if (Stat=WriteStringToFile(File,ActualAccount->Name))
				throw (DWORD)Stat;

			if (Stat=WriteStringToFile(File,ActualAccount->Server->Name))
				throw (DWORD)Stat;

			if (!WriteFile(File,(char *)&ActualAccount->Server->Port,2,&WrittenBytes,NULL))
				throw (DWORD)EACC_SYSTEM;

			if ((Stat=WriteStringToFile(File,ActualAccount->Server->Login)))
				throw (DWORD)Stat;

			CodeDecodeString(ActualAccount->Server->Passwd,TRUE);

			if (Stat=WriteStringToFile(File,ActualAccount->Server->Passwd))
			{
				CodeDecodeString(ActualAccount->Server->Passwd,FALSE);
				throw (DWORD)Stat;
			}
			CodeDecodeString(ActualAccount->Server->Passwd,FALSE);

			if ((!WriteFile(File,(char *)&ActualAccount->Flags,sizeof(DWORD),&WrittenBytes,NULL) ||
				(!WriteFile(File,(char *)&ActualAccount->StatusFlags,sizeof(DWORD),&WrittenBytes,NULL)) ||
				(!WriteFile(File,(char *)&ActualAccount->PluginFlags,sizeof(DWORD),&WrittenBytes,NULL))))
				throw (DWORD)EACC_SYSTEM;

			if (!WriteFile(File,(char *)&ActualAccount->Interval,sizeof(WORD),&WrittenBytes,NULL))
				throw (DWORD)EACC_SYSTEM;

			if ((!WriteFile(File,(char *)&ActualAccount->NewMailN.Flags,sizeof(DWORD),&WrittenBytes,NULL)) ||
				(!WriteFile(File,(char *)&ActualAccount->NewMailN.PopupB,sizeof(COLORREF),&WrittenBytes,NULL)) ||
				(!WriteFile(File,(char *)&ActualAccount->NewMailN.PopupT,sizeof(COLORREF),&WrittenBytes,NULL)) ||
				(!WriteFile(File,(char *)&ActualAccount->NewMailN.PopupTime,sizeof(DWORD),&WrittenBytes,NULL)))
				throw (DWORD)EACC_SYSTEM;

			if ((Stat=WriteStringToFileW(File,ActualAccount->NewMailN.App)) ||
				(Stat=WriteStringToFileW(File,ActualAccount->NewMailN.AppParam)))
				throw (DWORD)Stat;

			if ((!WriteFile(File,(char *)&ActualAccount->NoNewMailN.Flags,sizeof(DWORD),&WrittenBytes,NULL)) ||
				(!WriteFile(File,(char *)&ActualAccount->NoNewMailN.PopupB,sizeof(COLORREF),&WrittenBytes,NULL)) ||
				(!WriteFile(File,(char *)&ActualAccount->NoNewMailN.PopupT,sizeof(COLORREF),&WrittenBytes,NULL)) ||
				(!WriteFile(File,(char *)&ActualAccount->NoNewMailN.PopupTime,sizeof(DWORD),&WrittenBytes,NULL)))
				throw (DWORD)EACC_SYSTEM;

			if ((Stat=WriteStringToFileW(File,ActualAccount->NoNewMailN.App)) ||
				(Stat=WriteStringToFileW(File,ActualAccount->NoNewMailN.AppParam)))
				throw (DWORD)Stat;

			if ((!WriteFile(File,(char *)&ActualAccount->BadConnectN.Flags,sizeof(DWORD),&WrittenBytes,NULL)) ||
				(!WriteFile(File,(char *)&ActualAccount->BadConnectN.PopupB,sizeof(COLORREF),&WrittenBytes,NULL)) ||
				(!WriteFile(File,(char *)&ActualAccount->BadConnectN.PopupT,sizeof(COLORREF),&WrittenBytes,NULL)) ||
				(!WriteFile(File,(char *)&ActualAccount->BadConnectN.PopupTime,sizeof(DWORD),&WrittenBytes,NULL)))
				throw (DWORD)EACC_SYSTEM;

			if ((Stat=WriteStringToFileW(File,ActualAccount->BadConnectN.App)) ||
				(Stat=WriteStringToFileW(File,ActualAccount->BadConnectN.AppParam)))
				throw (DWORD)Stat;

//Let plugin write its own values into file
			if (ActualAccount->Plugin->Fcn != NULL && ActualAccount->Plugin->Fcn->WritePluginOptsFcnPtr != NULL)
				if (Stat=ActualAccount->Plugin->Fcn->WritePluginOptsFcnPtr(File,ActualAccount))
					throw (DWORD)Stat;
#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountMsgsSO-read wait\n");
#endif
			WaitToReadFcn(ActualAccount->MessagesAccessSO);
#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountMsgsSO-read enter\n");
#endif
			if (Stat=WriteMessagesToFile(File,ActualAccount))
			{
#ifdef DEBUG_SYNCHRO
				DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountMsgsSO-read done\n");
#endif
				ReadDoneFcn(ActualAccount->MessagesAccessSO);
				throw (DWORD)Stat;
			}
#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountMsgsSO-read done\n");
#endif
			ReadDoneFcn(ActualAccount->MessagesAccessSO);

			if ((!WriteFile(File,(char *)&ActualAccount->LastChecked,sizeof(SYSTEMTIME),&WrittenBytes,NULL)) ||
				(!WriteFile(File,(char *)&ActualAccount->LastSChecked,sizeof(SYSTEMTIME),&WrittenBytes,NULL)) ||
				(!WriteFile(File,(char *)&ActualAccount->LastSynchronised,sizeof(SYSTEMTIME),&WrittenBytes,NULL)) ||
				(!WriteFile(File,(char *)&ActualAccount->LastMail,sizeof(SYSTEMTIME),&WrittenBytes,NULL)))
				throw (DWORD)Stat;

#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read done\n");
#endif
			ReadDoneFcn(ActualAccount->AccountAccessSO);
		}
	}
	catch(DWORD ErrorCode)
	{
#ifdef DEBUG_SYNCHRO
		DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read done\n");
#endif
		ReadDoneFcn(ActualAccount->AccountAccessSO);
		ReturnValue=ErrorCode;
	}
#ifdef DEBUG_SYNCHRO
	DebugLog(SynchroFile,"WriteAccountsToFile:AccountBrowserSO-read done\n");
#endif
	SWMRGDoneReading(Plugin->AccountBrowserSO);
	CloseHandle(File);
	return 0;
}
示例#4
0
LRESULT CALLBACK BadConnectPopUpProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) 
{
	DWORD PluginParam;
	switch(msg)
	{
		case WM_COMMAND:
			if((HIWORD(wParam)==STN_CLICKED) && (CallService(MS_POPUP_GETPLUGINDATA,(WPARAM)hWnd,(LPARAM)&PluginParam)))	//if clicked and it's new mail popup window
			{
				PROCESS_INFORMATION pi;
				STARTUPINFOW si;
				HACCOUNT ActualAccount;

				ZeroMemory(&si,sizeof(si));
				si.cb=sizeof(si);
				ActualAccount=(HACCOUNT)CallService(MS_POPUP_GETCONTACT,(WPARAM)hWnd,(LPARAM)0);
#ifdef DEBUG_SYNCHRO
				DebugLog(SynchroFile,"PopUpProc:LEFTCLICK:ActualAccountSO-read wait\n");
#endif
				if(WAIT_OBJECT_0==WaitToReadFcn(ActualAccount->AccountAccessSO))
				{
#ifdef DEBUG_SYNCHRO
					DebugLog(SynchroFile,"PopUpProc:LEFTCLICK:ActualAccountSO-read enter\n");
#endif
					if(ActualAccount->BadConnectN.App!=NULL)
					{
						WCHAR *Command;
						if(ActualAccount->BadConnectN.AppParam!=NULL)
							Command=new WCHAR[wcslen(ActualAccount->BadConnectN.App)+wcslen(ActualAccount->BadConnectN.AppParam)+6];
						else
							Command=new WCHAR[wcslen(ActualAccount->BadConnectN.App)+6];
	
						if(Command!=NULL)
						{
							lstrcpyW(Command,L"\"");
							lstrcatW(Command,ActualAccount->BadConnectN.App);
							lstrcatW(Command,L"\" ");
							if(ActualAccount->BadConnectN.AppParam!=NULL)
								lstrcatW(Command,ActualAccount->BadConnectN.AppParam);
							CreateProcessW(NULL,Command,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi);
							delete[] Command;
						}
					}
#ifdef DEBUG_SYNCHRO
					DebugLog(SynchroFile,"PopUpProc:LEFTCLICK:ActualAccountSO-read done\n");
#endif
					ReadDoneFcn(ActualAccount->AccountAccessSO);
				}
#ifdef DEBUG_SYNCHRO
				else
					DebugLog(SynchroFile,"PopUpProc:LEFTCLICK:ActualAccountSO-read enter failed\n");
#endif
				SendMessage(hWnd,UM_DESTROYPOPUP,0,0);
			}
			break;
		case UM_FREEPLUGINDATA:
			//Here we'd free our own data, if we had it.
			return FALSE;
		case UM_INITPOPUP:
			//This is the equivalent to WM_INITDIALOG you'd get if you were the maker of dialog popups.
			break;
		case WM_CONTEXTMENU:
			SendMessage(hWnd,UM_DESTROYPOPUP,0,0);
			break;
		case WM_NOTIFY:
/*			switch(((LPNMHDR)lParam)->code)
			{
				case NM_CLICK:
				{
				}
			}
			break;
*/		default:
			break;
	}
	return DefWindowProc(hWnd,msg,wParam,lParam);
}
示例#5
0
DWORD WINAPI BadConnection(LPVOID Param)
{
	MSG msg;
	HWND hBadConnect;
	HACCOUNT ActualAccount;
	struct BadConnectionParam MyParam;
	NOTIFYICONDATA nid;
	TCHAR *NotIconText=Translate(" - connection error");
	TCHAR *src,*dest;
	int i;

	MyParam=*(struct BadConnectionParam *)Param;
	ActualAccount=MyParam.account;
#ifdef DEBUG_SYNCHRO
	DebugLog(SynchroFile,"BadConnect:Incrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
#endif
	SCIncFcn(ActualAccount->UsingThreads);

//	we will not use params in stack anymore
	SetEvent(MyParam.ThreadRunningEV);

	__try
	{
		hBadConnect=CreateDialogParam(YAMNVar.hInst,MAKEINTRESOURCE(IDD_DLGBADCONNECT),NULL,(DLGPROC)DlgProcYAMNBadConnection,(LPARAM)&MyParam);
		SendMessage(hBadConnect,WM_SETICON,ICON_BIG,(LPARAM)hYamnIcons[3]);
		SendMessage(hBadConnect,WM_SETICON,ICON_SMALL,(LPARAM)hYamnIcons[3]);

		ZeroMemory(&nid,sizeof(nid));
		nid.cbSize=sizeof(NOTIFYICONDATA);
		nid.hWnd=hBadConnect;
		nid.hIcon=hYamnIcons[3];
		nid.uID=0;
		nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP;
		nid.uCallbackMessage=WM_YAMN_NOTIFYICON;

#ifdef DEBUG_SYNCHRO
		DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read wait\n");
#endif
		if(WAIT_OBJECT_0!=WaitToReadFcn(ActualAccount->AccountAccessSO))
		{
#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read wait failed\n");
#endif
			return 0;
		}
#ifdef DEBUG_SYNCHRO
		DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read enter\n");
#endif
		for(src=ActualAccount->Name,dest=nid.szTip,i=0;(*src!=(TCHAR)0) && (i+1<sizeof(nid.szTip));*dest++=*src++);
		for(src=NotIconText;(*src!=(TCHAR)0) && (i+1<sizeof(nid.szTip));*dest++=*src++);
		*dest=(TCHAR)0;

		if(ActualAccount->BadConnectN.Flags & YAMN_ACC_SND)
			CallService(MS_SKIN_PLAYSOUND,0,(LPARAM)YAMN_CONNECTFAILSOUND);
		if(ActualAccount->BadConnectN.Flags & YAMN_ACC_MSG)
			ShowWindow(hBadConnect,SW_SHOWNORMAL);
		if(ActualAccount->BadConnectN.Flags & YAMN_ACC_ICO)
			Shell_NotifyIcon(NIM_ADD,&nid);
#ifdef DEBUG_SYNCHRO
		DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read done\n");
#endif
		ReadDoneFcn(ActualAccount->AccountAccessSO);

		UpdateWindow(hBadConnect);
		while(GetMessage(&msg,NULL,0,0))
		{
			TranslateMessage(&msg); 
			DispatchMessage(&msg);  
		}

//	now, write to file. Why? Because we want to write when was new mail last checked
		if((ActualAccount->Plugin->Fcn!=NULL) && (ActualAccount->Plugin->Fcn->WriteAccountsFcnPtr!=NULL) && ActualAccount->AbleToWork)
			ActualAccount->Plugin->Fcn->WriteAccountsFcnPtr();
	}
	__finally
	{
#ifdef DEBUG_SYNCHRO
		DebugLog(SynchroFile,"BadConnect:Decrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
#endif
		SCDecFcn(ActualAccount->UsingThreads);
	}
	return 0;
}
示例#6
0
LRESULT CALLBACK DlgProcYAMNBadConnection(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
	switch(msg)
	{
		case WM_INITDIALOG:
		{
			BOOL ShowPopUp,ShowMsg,ShowIco;
			HACCOUNT ActualAccount;
			DWORD ErrorCode;
			char *TitleStrA;
			char *Message1A=NULL;
			WCHAR *Message1W=NULL;
			POPUPDATAEX BadConnectPopUp;

			ActualAccount=((struct BadConnectionParam *)lParam)->account;
			ErrorCode=((struct BadConnectionParam *)lParam)->errcode;
#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read wait\n");
#endif
			if(WAIT_OBJECT_0!=WaitToReadFcn(ActualAccount->AccountAccessSO))
			{
#ifdef DEBUG_SYNCHRO
				DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read wait failed\n");
#endif
				return FALSE;
			}
#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read enter\n");
#endif
			TitleStrA=new char[strlen(ActualAccount->Name)+strlen(Translate(BADCONNECTTITLE))];
			sprintf(TitleStrA,Translate(BADCONNECTTITLE),ActualAccount->Name);

			ShowPopUp=ActualAccount->BadConnectN.Flags & YAMN_ACC_POP;
			ShowMsg=ActualAccount->BadConnectN.Flags & YAMN_ACC_MSG;
			ShowIco=ActualAccount->BadConnectN.Flags & YAMN_ACC_ICO;

			if(ShowPopUp)
			{
				BadConnectPopUp.lchContact=ActualAccount;
				BadConnectPopUp.lchIcon=hYamnIcons[3];
				BadConnectPopUp.colorBack=ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC ? ActualAccount->BadConnectN.PopUpB : GetSysColor(COLOR_BTNFACE);
				BadConnectPopUp.colorText=ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC ? ActualAccount->BadConnectN.PopUpT : GetSysColor(COLOR_WINDOWTEXT);
				BadConnectPopUp.iSeconds=ActualAccount->BadConnectN.PopUpTime;

				BadConnectPopUp.PluginWindowProc=(WNDPROC)BadConnectPopUpProc;
				BadConnectPopUp.PluginData=0;					//it's bad connect popup
				lstrcpyn(BadConnectPopUp.lpzContactName,ActualAccount->Name,sizeof(BadConnectPopUp.lpzContactName));
			}

			if(ActualAccount->Plugin->Fcn!=NULL && ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr!=NULL)
			{
				Message1W=ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr(ErrorCode);
				SendMessageW(GetDlgItem(hDlg,IDC_STATICMSG),WM_SETTEXT,(WPARAM)0,(LPARAM)Message1W);
				WideCharToMultiByte(CP_ACP,0,Message1W,-1,(char *)BadConnectPopUp.lpzText,sizeof(BadConnectPopUp.lpzText),NULL,NULL);
				if(ShowPopUp)
					CallService(MS_POPUP_ADDPOPUPEX,(WPARAM)&BadConnectPopUp,0);
			}
			else if(ActualAccount->Plugin->Fcn!=NULL && ActualAccount->Plugin->Fcn->GetErrorStringAFcnPtr!=NULL)
			{
				Message1A=ActualAccount->Plugin->Fcn->GetErrorStringAFcnPtr(ErrorCode);
				SendMessageA(GetDlgItem(hDlg,IDC_STATICMSG),WM_SETTEXT,(WPARAM)0,(LPARAM)Message1A);
				lstrcpyn(BadConnectPopUp.lpzText,Message1A,sizeof(BadConnectPopUp.lpzText));
				if(ShowPopUp)
					CallService(MS_POPUP_ADDPOPUPEX,(WPARAM)&BadConnectPopUp,0);
			}
			else
			{
				Message1A=Translate("Unknown error");
				SendMessageA(GetDlgItem(hDlg,IDC_STATICMSG),WM_SETTEXT,(WPARAM)0,(LPARAM)Message1A);
				lstrcpyn(BadConnectPopUp.lpzText,Message1A,sizeof(BadConnectPopUp.lpzText));
				if(ShowPopUp)
					CallService(MS_POPUP_ADDPOPUPEX,(WPARAM)&BadConnectPopUp,0);
			}

			if(!ShowMsg && !ShowIco)
				DestroyWindow(hDlg);
#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read done\n");
#endif
			ReadDoneFcn(ActualAccount->AccountAccessSO);

			SendMessage(hDlg,WM_SETTEXT,(WPARAM)0,(LPARAM)TitleStrA);
			delete[] TitleStrA;
			if(Message1A!=NULL)
				delete[] Message1A;
			if(ActualAccount->Plugin->Fcn!=NULL && ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr!=NULL && Message1A!=NULL)
				ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr(Message1A);
			if(ActualAccount->Plugin->Fcn!=NULL && ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr!=NULL && Message1W!=NULL)
				ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr(Message1W);
			return 0;
		}
		case WM_DESTROY:
		{
			NOTIFYICONDATA nid;

			ZeroMemory(&nid,sizeof(NOTIFYICONDATA));
			nid.cbSize=sizeof(NOTIFYICONDATA);
			nid.hWnd=hDlg;
			nid.uID=0;
			Shell_NotifyIcon(NIM_DELETE,&nid);
			PostQuitMessage(0);
			break;
		}
		case WM_YAMN_NOTIFYICON:
			switch (lParam)
			{
				case WM_LBUTTONDBLCLK:
				          ShowWindow(hDlg,SW_SHOWNORMAL);
				          SetForegroundWindow(hDlg);
				          break;
			}
			return 0;
		case WM_CHAR:
			switch((TCHAR)wParam)
			{
				case 27:
				case 13:
					DestroyWindow(hDlg);
					break;
			}
			break;
		case WM_SYSCOMMAND:
			switch(wParam)
			{
				case SC_CLOSE:
					DestroyWindow(hDlg);
					break;
			}
		case WM_COMMAND:
		{
			WORD wNotifyCode = HIWORD(wParam);
			switch(LOWORD(wParam))
			{
				case IDC_BTNOK:
					DestroyWindow(hDlg);
					break;
			}
			break;
		}
	}
	return 0;
}
示例#7
0
static INT_PTR ContactMailCheck(WPARAM wParam, LPARAM lParam)
{

	DBVARIANT dbv;
	char *szProto;
	HACCOUNT ActualAccount;
	HANDLE ThreadRunningEV;
	DWORD tid;

	szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0);
	if(szProto != NULL && strcmp(szProto, ProtoName)==0)
	{
		if(!DBGetContactSetting((HANDLE) wParam,ProtoName,"Id",&dbv)) 
		{
			ActualAccount=(HACCOUNT) CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)dbv.pszVal);
			if(ActualAccount != NULL)
			{
				//we use event to signal, that running thread has all needed stack parameters copied
				if(NULL==(ThreadRunningEV=CreateEvent(NULL,FALSE,FALSE,NULL)))
					return 0;
				//if we want to close miranda, we get event and do not run pop3 checking anymore
				if(WAIT_OBJECT_0==WaitForSingleObject(ExitEV,0))
					return 0;
				EnterCriticalSection(PluginRegCS);
				#ifdef DEBUG_SYNCHRO
				DebugLog(SynchroFile,"ForceCheck:ActualAccountSO-read wait\n");
				#endif
				if(WAIT_OBJECT_0!=WaitToReadFcn(ActualAccount->AccountAccessSO))
				{
					#ifdef DEBUG_SYNCHRO
					DebugLog(SynchroFile,"ForceCheck:ActualAccountSO-read wait failed\n");
					#endif
				}
				else
				{
					#ifdef DEBUG_SYNCHRO
					DebugLog(SynchroFile,"ForceCheck:ActualAccountSO-read enter\n");
					#endif
					if((ActualAccount->Flags & YAMN_ACC_ENA) && (ActualAccount->StatusFlags & YAMN_ACC_FORCE))			//account cannot be forced to check
					{
						if(ActualAccount->Plugin->Fcn->ForceCheckFcnPtr==NULL)
						{
							ReadDoneFcn(ActualAccount->AccountAccessSO);
						}
						struct CheckParam ParamToPlugin={YAMN_CHECKVERSION,ThreadRunningEV,ActualAccount,YAMN_FORCECHECK,(void *)0,NULL};

						if(NULL==CreateThread(NULL,0,(YAMN_STANDARDFCN)ActualAccount->Plugin->Fcn->ForceCheckFcnPtr,&ParamToPlugin,0,&tid))
						{
							ReadDoneFcn(ActualAccount->AccountAccessSO);
						}
						else
							WaitForSingleObject(ThreadRunningEV,INFINITE);
					}
					ReadDoneFcn(ActualAccount->AccountAccessSO);
				}
				LeaveCriticalSection(PluginRegCS);
				CloseHandle(ThreadRunningEV);
			}
			DBFreeVariant(&dbv);
		}

	}
	return 0;
}
示例#8
0
static INT_PTR ContactApplication(WPARAM wParam, LPARAM lParam)
{
	DBVARIANT dbv;
	char *szProto;
	HACCOUNT ActualAccount;

	szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0);
	if(szProto != NULL && strcmp(szProto, ProtoName)==0)
	{
		if(!DBGetContactSetting((HANDLE) wParam,ProtoName,"Id",&dbv)) 
		{
			ActualAccount=(HACCOUNT) CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)dbv.pszVal);
			if(ActualAccount != NULL)
			{
				PROCESS_INFORMATION pi;
				STARTUPINFOW si;

				ZeroMemory(&si,sizeof(si));
				si.cb=sizeof(si);
				
				#ifdef DEBUG_SYNCHRO
				DebugLog(SynchroFile,"ContactApplication:ActualAccountSO-read wait\n");
				#endif
				if(WAIT_OBJECT_0==WaitToReadFcn(ActualAccount->AccountAccessSO))
				{
					#ifdef DEBUG_SYNCHRO
					DebugLog(SynchroFile,"ContactApplication:ualAccountSO-read enter\n");
					#endif
					if(ActualAccount->NewMailN.App!=NULL)
					{
						WCHAR *Command;
						if(ActualAccount->NewMailN.AppParam!=NULL)
							Command=new WCHAR[wcslen(ActualAccount->NewMailN.App)+wcslen(ActualAccount->NewMailN.AppParam)+6];
						else
							Command=new WCHAR[wcslen(ActualAccount->NewMailN.App)+6];
					
						if(Command!=NULL)
						{
							lstrcpyW(Command,L"\"");
							lstrcatW(Command,ActualAccount->NewMailN.App);
							lstrcatW(Command,L"\" ");
							if(ActualAccount->NewMailN.AppParam!=NULL)
								lstrcatW(Command,ActualAccount->NewMailN.AppParam);
							CreateProcessW(NULL,Command,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi);
							delete[] Command;
						}
					}

					#ifdef DEBUG_SYNCHRO
					DebugLog(SynchroFile,"ContactApplication:ActualAccountSO-read done\n");
					#endif
					ReadDoneFcn(ActualAccount->AccountAccessSO);
				}
				#ifdef DEBUG_SYNCHRO
				else
					DebugLog(SynchroFile,"ContactApplication:ActualAccountSO-read enter failed\n");
				#endif
			}
			DBFreeVariant(&dbv);
		}
	}
	return 0;
}
示例#9
0
INT_PTR CALLBACK DlgProcYAMNBadConnection(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
	switch(msg)
	{
		case WM_INITDIALOG:
		{
			BOOL ShowPopup,ShowMsg,ShowIco;
			HACCOUNT ActualAccount;
			DWORD  ErrorCode;
			char* TitleStrA;
			char *Message1A=NULL;
			TCHAR *Message1W=NULL;
			POPUPDATAT BadConnectPopup;

			ActualAccount=((struct BadConnectionParam *)lParam)->account;
			ErrorCode=((struct BadConnectionParam *)lParam)->errcode;
#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read wait\n");
#endif
			if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO))
			{
#ifdef DEBUG_SYNCHRO
				DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read wait failed\n");
#endif
				return FALSE;
			}
#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read enter\n");
#endif
			int size = (int)(strlen(ActualAccount->Name)+strlen(Translate(BADCONNECTTITLE)));
			TitleStrA = new char[size];
			mir_snprintf(TitleStrA, size, Translate(BADCONNECTTITLE), ActualAccount->Name);

			ShowPopup=ActualAccount->BadConnectN.Flags & YAMN_ACC_POP;
			ShowMsg=ActualAccount->BadConnectN.Flags & YAMN_ACC_MSG;
			ShowIco=ActualAccount->BadConnectN.Flags & YAMN_ACC_ICO;

			if (ShowPopup) {
				BadConnectPopup.lchIcon = g_LoadIconEx(3);
				BadConnectPopup.colorBack = ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC ? ActualAccount->BadConnectN.PopupB : GetSysColor(COLOR_BTNFACE);
				BadConnectPopup.colorText = ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC ? ActualAccount->BadConnectN.PopupT : GetSysColor(COLOR_WINDOWTEXT);
				BadConnectPopup.iSeconds = ActualAccount->BadConnectN.PopupTime;

				BadConnectPopup.PluginWindowProc = BadConnectPopupProc;
				BadConnectPopup.PluginData = ActualAccount;
				lstrcpyn(BadConnectPopup.lptzContactName, _A2T(ActualAccount->Name), SIZEOF(BadConnectPopup.lptzContactName));
			}

			if (ActualAccount->Plugin->Fcn != NULL && ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr != NULL) {
				Message1W = ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr(ErrorCode);
				SetDlgItemText(hDlg,IDC_STATICMSG,Message1W);
				lstrcpyn(BadConnectPopup.lptzText,Message1W,sizeof(BadConnectPopup.lptzText));
				if (ShowPopup)
					PUAddPopupT(&BadConnectPopup);
			}
			else if (ActualAccount->Plugin->Fcn != NULL && ActualAccount->Plugin->Fcn->GetErrorStringAFcnPtr != NULL)
			{
				Message1W=ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr(ErrorCode);
				SetDlgItemText(hDlg,IDC_STATICMSG,Message1W);
				lstrcpyn(BadConnectPopup.lptzText,Message1W,sizeof(BadConnectPopup.lptzText));
				if (ShowPopup)
					PUAddPopupT(&BadConnectPopup);
			}
			else
			{
				Message1W=TranslateT("Unknown error");
				SetDlgItemText(hDlg,IDC_STATICMSG,Message1W);
				lstrcpyn(BadConnectPopup.lptzText,Message1W,sizeof(BadConnectPopup.lptzText));
				if (ShowPopup)
					PUAddPopupT(&BadConnectPopup);
			}

			if (!ShowMsg && !ShowIco)
				DestroyWindow(hDlg);
#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read done\n");
#endif
			ReadDoneFcn(ActualAccount->AccountAccessSO);

			SetWindowTextA(hDlg, TitleStrA);
			delete[] TitleStrA;
			if (Message1A != NULL)
				delete[] Message1A;
			if (ActualAccount->Plugin->Fcn != NULL && ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr != NULL && Message1A != NULL)
				ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr(Message1A);
			if (ActualAccount->Plugin->Fcn != NULL && ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr != NULL && Message1W != NULL)
				ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr(Message1W);
			return 0;
		}
		case WM_DESTROY:
		{
			NOTIFYICONDATA nid;

			ZeroMemory(&nid,sizeof(NOTIFYICONDATA));
			nid.cbSize=sizeof(NOTIFYICONDATA);
			nid.hWnd=hDlg;
			nid.uID=0;
			Shell_NotifyIcon(NIM_DELETE,&nid);
			PostQuitMessage(0);
			break;
		}
		case WM_YAMN_NOTIFYICON:
			switch (lParam)
			{
				case WM_LBUTTONDBLCLK:
				          ShowWindow(hDlg,SW_SHOWNORMAL);
				          SetForegroundWindow(hDlg);
				          break;
			}
			return 0;
		case WM_CHAR:
			switch((TCHAR)wParam)
			{
				case 27:
				case 13:
					DestroyWindow(hDlg);
					break;
			}
			break;
		case WM_SYSCOMMAND:
			switch(wParam)
			{
				case SC_CLOSE:
					DestroyWindow(hDlg);
					break;
			}
		case WM_COMMAND:
		{
			WORD wNotifyCode = HIWORD(wParam);
			switch(LOWORD(wParam))
			{
				case IDC_BTNOK:
					DestroyWindow(hDlg);
					break;
			}
			break;
		}
	}
	return 0;
}