Example #1
0
extern "C" DWORD PASCAL EXPORT STDFUFILES_DestroyImage(PHANDLE pHandle)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	BOOL bFound=FALSE;
	DWORD dwRet=STDFUFILES_NOERROR;

	for (int i=0;i<=g_Images.GetUpperBound();i++)
	{
		if ((HANDLE)g_Images.GetAt(i)==*pHandle)
		{
			CImage *pImage=(CImage *)(*pHandle);
			
			delete pImage;
			*pHandle=0;
			bFound=TRUE;
			g_Images.RemoveAt(i);
			break;
		}
	}

	if (!bFound)
		dwRet=STDFUFILES_BADPARAMETER;
	return dwRet;
}
Example #2
0
extern "C" DWORD PASCAL EXPORT STDFUFILES_FilterImageForOperation(HANDLE Handle, PMAPPING pMapping, DWORD Operation, BOOL bTruncateLeadFFForUpgrade)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	BOOL bFound=FALSE;
	DWORD dwRet=STDFUFILES_NOERROR;

	if (!pMapping)
		return STDFUFILES_BADPARAMETER;

	for (int i=0;i<=g_Images.GetUpperBound();i++)
	{
		if ((HANDLE)g_Images.GetAt(i)==Handle)
		{
			CImage *pImage=(CImage *)Handle;
			
			bFound=pImage->FilterImageForOperation(pMapping, Operation, bTruncateLeadFFForUpgrade);
			break;
		}
	}

	if (!bFound)
		dwRet=STDFUFILES_BADPARAMETER;
	return dwRet;
}
Example #3
0
extern "C" DWORD PASCAL EXPORT STDFUFILES_ReadImageFromDFUFile(HANDLE hFile, 
															 int Rank, 
															 PHANDLE pImage)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	BOOL bFound=FALSE;
	DWORD dwRet=STDFUPRT_NOERROR;

	for (int i=0;i<=g_DFUFiles.GetUpperBound();i++)
	{
		if ((HANDLE)g_DFUFiles.GetAt(i)==hFile)
		{
			CDFUFile *pFile=(CDFUFile *)hFile;

			dwRet=pFile->ReadImage(Rank, pImage);

			if (dwRet==STDFUFILES_NOERROR) 
				g_Images.Add((CImage*)*pImage);
	
			bFound=TRUE;
			break;
		}
	}
	if (!bFound)
		dwRet=STDFUPRT_BADPARAMETER;
	return dwRet;
}
Example #4
0
extern "C" DWORD PASCAL EXPORT STDFUFILES_DuplicateImage(HANDLE hSource, PHANDLE pDest)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	
	DWORD dwRet=STDFUFILES_NOERROR;
	BOOL bFound=FALSE;

	for (int i=0;i<=g_Images.GetUpperBound();i++)
	{
		if ((HANDLE)g_Images.GetAt(i)==hSource)
		{
			bFound=TRUE;
			break;
		}
	}

	if (!bFound)
		dwRet=STDFUPRT_BADPARAMETER;
	else
	{
		CImage *obImage=new CImage((CImage*)hSource);
		if (obImage->GetImageState())
		{
			g_Images.Add(obImage);
			*pDest=(HANDLE)obImage;
		}
		else
		{
			delete obImage;
			dwRet=STDFUFILES_BADFORMAT;
		}
	}
	return dwRet;
}
Example #5
0
int CSTDFUFILESApp::ExitInstance() 
{
	int i;
	for (i=0;i<=g_Images.GetUpperBound();i++)
	{
		CImage *pImage=(CImage*)g_Images.GetAt(i);

		delete pImage;
	}
	g_Images.RemoveAll();
	for (i=0;i<=g_DFUFiles.GetUpperBound();i++)
	{
		CDFUFile *pFile=(CDFUFile*)g_DFUFiles.GetAt(i);
		delete pFile;
	}
	g_DFUFiles.RemoveAll();
	return CWinApp::ExitInstance();
}
Example #6
0
/**
* SyncServerConnections
*
*/
void CFtpManager::SyncServerConnections()
{
	CConnectionManager connectionManager;
	connectionManager.Load();
	CObArray * listOfConnections;
	listOfConnections = connectionManager.GetConnections();
	int i = 0;
	for(i = 0; i <  listOfConnections->GetSize(); i++){
		CConnection * con = (CConnection *)listOfConnections->GetAt(i);
		if(con->host.GetLength() > 0)
		{
			SyncServerConnection(con);
		}
	}
}
Example #7
0
extern "C" DWORD PASCAL EXPORT STDFUFILES_GetImageSize(HANDLE Image)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	DWORD dwRet=STDFUFILES_NOERROR;

	for (int i=0;i<=g_Images.GetUpperBound();i++)
	{
		if ((HANDLE)g_Images.GetAt(i)==Image)
		{
			CImage *pImage=(CImage *)Image;
			
			return pImage->GetSize(); 
			break;
		}
	}
}
Example #8
0
LRESULT CSessionWnd::OnExecuteComplete(WPARAM wParam, LPARAM lParam)
{
	WFSRESULT *pResult = (WFSRESULT *)lParam;
	// finding serviceBasic
	CServiceBasic *pServiceBasic = 0;
	for(long i=0; i<g_arrayService.GetSize(); i++)
	{
		pServiceBasic = (CServiceBasic *)g_arrayService.GetAt(i);
		if(pServiceBasic->m_nRequestedID == pResult->RequestID)
		{
			pServiceBasic->m_hResult = pResult->hResult;
			*pServiceBasic->m_lppResult = pResult;
			break;
		}
		pServiceBasic = 0;
	}
	if(pServiceBasic) pServiceBasic->m_nRequestedID = 0;
	if(pServiceBasic) pServiceBasic->m_eventExecute.SetEvent();
	return 0;
}
Example #9
0
extern "C" DWORD PASCAL EXPORT STDFUFILES_CloseDFUFile(HANDLE hFile)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	BOOL bFound=FALSE;
	DWORD dwRet=STDFUPRT_NOERROR;

	for (int i=0;i<=g_DFUFiles.GetUpperBound();i++)
	{
		if ((HANDLE)g_DFUFiles.GetAt(i)==hFile)
		{
			CDFUFile *pFile=(CDFUFile *)hFile;
			delete pFile;
			g_DFUFiles.RemoveAt(i);
			bFound=TRUE;
			break;
		}
	}
	if (!bFound)
		dwRet=STDFUPRT_BADPARAMETER;
	return dwRet;
}
Example #10
0
extern "C" DWORD PASCAL EXPORT STDFUFILES_DestroyImageElement(HANDLE Handle, DWORD dwRank)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	BOOL bFound=FALSE;
	DWORD dwRet=STDFUFILES_NOERROR;

	for (int i=0;i<=g_Images.GetUpperBound();i++)
	{
		if ((HANDLE)g_Images.GetAt(i)==Handle)
		{
			CImage *pImage=(CImage *)Handle;
			
			bFound=pImage->DestroyImageElement(dwRank);
			break;
		}
	}

	if (!bFound)
		dwRet=STDFUFILES_BADPARAMETER;
	return dwRet;
}
Example #11
0
extern "C" DWORD PASCAL EXPORT STDFUFILES_SetImageName(HANDLE Image, PSTR Name)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	BOOL bFound=FALSE;
	DWORD dwRet=STDFUFILES_NOERROR;

	for (int i=0;i<=g_Images.GetUpperBound();i++)
	{
		if ((HANDLE)g_Images.GetAt(i)==Image)
		{
			CImage *pImage=(CImage *)(Image);
			
			pImage->SetName(Name);
			bFound=TRUE;
			break;
		}
	}

	if (!bFound)
		dwRet=STDFUFILES_BADPARAMETER;
	return dwRet;
}
Example #12
0
extern "C" DWORD PASCAL EXPORT STDFUFILES_ImageToFile(PSTR pPathFile, HANDLE Image)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	BOOL bFound=FALSE;
	DWORD dwRet=STDFUFILES_NOERROR;

	for (int i=0;i<=g_Images.GetUpperBound();i++)
	{
		if ((HANDLE)g_Images.GetAt(i)==Image)
		{
			CImage *pImage=(CImage *)(Image);
			
			if (!pImage->DumpToFile(pPathFile)) 
				dwRet=STDFUFILES_BADPARAMETER;
			bFound=TRUE;
			break;
		}
	}

	if (!bFound)
		dwRet=STDFUFILES_BADPARAMETER;
	return dwRet;
}
Example #13
0
// **************************************************************************
// WorkerThread ()
//
// Description:
//	Worker thread function.
//
// Parameters:
//	void		*pvArgs		Pointer to a WORKERTHREADARG structure which
//							  describes task to be performed.
//
// Returns:
//  unsigned int - 0
// **************************************************************************
unsigned _stdcall CKDocument::WorkerThread (void *pvArgs)
	{
	// Cast argument to proper type so we can extract the required data
	// about the task we are to perform:
	WORKERTHREADARG *pWTA = (WORKERTHREADARG *)pvArgs;
	ASSERT (pWTA);

	// Execute specified task:
	switch (pWTA->eTask)
		{
		case WORKERTHREADARG::START_SINGLE_SERVER:
		case WORKERTHREADARG::STOP_SINGLE_SERVER:
			{
			// Extract pointer to server we are to start or stop from
			// argument structure:
			CKServer *pServer = (CKServer *)pWTA->pvObjectA;
			ASSERT (pServer);

			// Start or stop the server as the case may be:
			if (pWTA->eTask == WORKERTHREADARG::START_SINGLE_SERVER)
				pServer->Start ();
			else
				pServer->Stop ();
			}
			break;

		case WORKERTHREADARG::START_MULTIPLE_SERVER:
		case WORKERTHREADARG::STOP_MULTIPLE_SERVER:
			{
			// Extract the list (object array) of servers to start or stop 
			// from argument structure:
			CObArray *pList = (CObArray *)pWTA->pvObjectA;
			ASSERT (pList);

			// Get the number of server in the list:
			int cnServers = pList->GetSize ();
			CKServer *pServer = NULL;

			// Loop over the servers in the list:
			while (--cnServers >= 0)
				{
				// Get pointer to next server in list:
				pServer = (CKServer *) pList->GetAt (cnServers);
				ASSERT (pServer);

				// Start or stop that server as the case may be:
				if (pWTA->eTask == WORKERTHREADARG::START_MULTIPLE_SERVER)
					pServer->Start ();
				else
					pServer->Stop ();
				}
			}
			break;

		case WORKERTHREADARG::ADD_ITEMS:
			{
			// Extract the list (object array) of items to add from
			// argument structure:
			CObArray *pList = (CObArray *)pWTA->pvObjectA;
			ASSERT (pList);

			// Extract the number of items from the argument structure:
			int cnItems = *(int *)pWTA->pvObjectB;

			// Get pointer to first item from list.  We will use it to
			// get the group object these items will be added to:
			CKItem *pItem = (CKItem *)pList->GetAt (0);
			ASSERT (pItem);

			// Get group that we are adding the items to:
			CKGroup *pGroup = pItem->GetParentGroup ();
			ASSERT (pGroup);

			// Add the items to this group:
			pGroup->AddItems (*pList, cnItems);
			}
			break;

		default:
			// unhandled task ?
			ASSERT (FALSE);
			break;
		}

	return (0);
	}
Example #14
0
/**
* OnLoadUrl
*
* Description: Load a url into the view
*
* Parameters:	wparam: - 0 = no callback, 1 = yes callback
*				lparam: CString url path
*/
LRESULT CMainFrame::OnLoadUrl(WPARAM wParam, LPARAM lParam)
{
	CConnectionListView * connectionView = (CConnectionListView *)m_mainSplitter.GetPane(0,0);
	CFileListView * fileListView = (CFileListView *)m_mainSplitter.GetPane(0,1);

	CString * urlArg = (CString*)lParam;
	if(urlArg){
		TRACE1(" Load url: %s \n", urlArg->AllocSysString());
		CString url(urlArg->AllocSysString());
		delete urlArg;

		CString host(_T(""));
		CString dir(_T(""));
		// Parse
		if(url.Find(_T("ftp://")) != -1){
			url = url.Mid(url.Find(_T("ftp://")) + 6, url.GetLength() - url.Find(_T("ftp://")));
		}
		int pos = url.Find('/');
		if(pos != -1){
			host = url.Mid(0, pos);
			dir = url.Mid(pos, url.GetLength() - pos);
		} else {
			host = CString(url);
			dir = CString(_T("/"));
		}

		// select connection
		int connection_id = -1;
		CObArray * listOfConnections;
		listOfConnections = m_connectionManager.GetConnections();
		int i = 0;
		for(i = 0; i < listOfConnections->GetSize(); i++){
			CConnection * con = (CConnection *)listOfConnections->GetAt(i);
			if(con->host.Compare(host) == 0){
				connection_id = i;
				connectionView->SelectConnection(connection_id);
			}
		}

		// Prompt for new connection information
		if(connection_id < 0){
			CConnectionDialog dlg;
			dlg.SetHost(host); // prefill in host
			dlg.DoModal();
	
			// Update view with updated connections
			connectionView->UpdateConnections();

			// Re check host in connections
			m_connectionManager.Load();
			listOfConnections = m_connectionManager.GetConnections();
			int i = 0;
			for(i = 0; i < listOfConnections->GetSize(); i++){
				CConnection * con = (CConnection *)listOfConnections->GetAt(i);
				if(con->host.Compare(host) == 0){
					connection_id = i;
					connectionView->SelectConnection(connection_id);
				}
			}
			if(connection_id < 0){
				return 1; // No connection entered, abort
			}
		}

		// Load file list view
		fileListView->LoadServerConnection(connection_id);
		fileListView->LoadDirectory(dir);

		// Load url in header history.
		if(m_headerDoc && ((int)wParam) == 1){
			m_headerDoc.SetUrl( CString(host + dir) );
			m_headerDoc.SetConnectionID(connection_id); 
			m_headerDoc.m_path = CString(dir);          // This needs work
			CFileListView * v = (CFileListView *)m_mainSplitter.GetPane(0,1);
			m_headerDoc.m_path = CString(v->GetPath());
		}

		// Cleanup
		delete urlArg;
	}
	return 1;
}
BOOL CExMapi::GetContacts(CObArray& contactArray,CTRError& error)
{
	BOOL doLog = m_pCtrl->IsEnableLog();
	if(doLog)
	{
		m_logHelper.LogPAB(L"------------------------------------");
		m_logHelper.LogPAB(L"Function GetPABCotacts START:");
		m_logHelper.LogPAB(L"------------------------------------");
	}

	CString strFilterBy = m_pCtrl->GetPABSerachBy();
	CString strStartWith = m_pCtrl->GetPABSerachStartWith();
	strStartWith = strStartWith.MakeLower();
	ULONG pageSize;
	m_pCtrl->get_PABPageSize(&pageSize);
	ULONG pageNumber = m_pCtrl->GetPABPageNumber();
	LONG contactCount = 0;
	LONG skipCount = 0;
	LONG startIndex = -1;
	LONG contactIndex = 0;
	LONG folderCount = 0;
	if(pageSize>0)
	{
		startIndex = (pageSize * pageNumber) - pageSize;
	}

	CString strFolder;
	int msgStoreCount = 0;
	wchar_t buffer[5];

	LPMAPIFOLDER pSubFolder=NULL;	
	LPMAPITABLE lpMsgStoreTable = NULL;
	lpMsgStoreTable = GetMessageStoresTable();	
	if(lpMsgStoreTable)
	{
		while(OpenNextMessageStore(lpMsgStoreTable))
		{	
			//GetContacts(OpenRootFolder(),folderCount,contactCount,skipCount,contactIndex,contactArray);

			msgStoreCount++;
			_itow(msgStoreCount,buffer,10);
			if(doLog)
			{
				if(msgStoreCount > 1)
					m_logHelper.LogPAB(L"-------------------------------------");
				m_logHelper.LogPAB(L"Message Store No : "+CString(buffer));
				m_logHelper.LogPAB(L"-------------------------------------");
			}

			pSubFolder = OpenContacts();
			if(pSubFolder && IsContactFolder(pSubFolder))
			{
				if(doLog)
					m_logHelper.LogPAB(L"Open Main Contacts Folder");

				strFolder = GetFolderName(pSubFolder);
				folderCount++;
				if(GetContents(pSubFolder))
				{
					SortContents(TABLE_SORT_ASCEND,PR_DISPLAY_NAME);
					//SortContents(TABLE_SORT_ASCEND,PR_SUBJECT);

					CString strText;
					CExMapiContact mapiContact;
					CString name;
					CString email;
					BOOL mustFilter = FALSE;
					mustFilter = strStartWith != "";
					
					if(doLog)
						m_logHelper.LogPAB(L"Start reading contacts from main contact fodler");

					while(GetNextContact(mapiContact) && !m_pCtrl->IsPABSearchAbort()) 
					{
						if(pageSize > 0)
						{
							if(contactCount == pageSize)
							{
								break;								
							}
						}

						contactIndex++;
						if(mustFilter)
						{
							if(strFilterBy == "Name")
							{
								mapiContact.GetName(name,PR_GIVEN_NAME);
								name = name.MakeLower();
								if(name.Find(strStartWith) != 0)				
								{
									continue;									
								}
							}

							if(strFilterBy == "Email")
							{
								mapiContact.GetEmail(email);
								email = email.MakeLower();
								if(email.Find(strStartWith) != 0)
								{
									continue;
								}
							}																
						}
						if(startIndex > 0 && skipCount < startIndex)
						{
							skipCount++;
							continue;								
						}

						CContact* pContact = new CContact();

						pContact->SetId(contactIndex);

						pContact->SetFolderName(strFolder);

						mapiContact.GetName(strText);
						pContact->SetFullName(strText);

						mapiContact.GetCompany(strText);
						pContact->SetCompany(strText);

						mapiContact.GetIMAddress(strText);
						pContact->SetIMAddress(strText);

						mapiContact.GetName(strText,PR_GIVEN_NAME);
						pContact->SetFirstName(strText);

						mapiContact.GetName(strText,PR_MIDDLE_NAME);
						pContact->SetMiddleName(strText);

						mapiContact.GetName(strText,PR_SURNAME);
						pContact->SetLastName(strText);

						mapiContact.GetEmail(strText);
						pContact->SetEmail(strText);	

						mapiContact.GetEmail(strText,2);//Email 2
						pContact->SetEmail2(strText);

						mapiContact.GetEmail(strText,3);//Email 3
						pContact->SetEmail3(strText);

						mapiContact.GetPhoneNumber(strText,PR_BUSINESS_TELEPHONE_NUMBER);
						pContact->SetBusinessPhone(strText);

						mapiContact.GetPhoneNumber(strText,PR_COMPANY_MAIN_PHONE_NUMBER);
						pContact->SetCompanyPhone(strText);

						mapiContact.GetPhoneNumber(strText,PR_BUSINESS_FAX_NUMBER);
						pContact->SetFax(strText);

						mapiContact.GetPhoneNumber(strText,PR_MOBILE_TELEPHONE_NUMBER);
						pContact->SetMobilePhone(strText);

						mapiContact.GetPhoneNumber(strText,PR_HOME_TELEPHONE_NUMBER);
						pContact->SetHomePhone(strText);

						if(m_pCtrl->FetchUnique())
						{
							BOOL isContactExist = FALSE;
							for(int i=0;i<contactArray.GetCount();i++)
							{
								CContact* pTemp = (CContact*)contactArray.GetAt(i);

								if(pContact->GetEmail() != "" && pTemp->GetEmail() == pContact->GetEmail())
								{
									isContactExist = TRUE;
									break;																	
								}
								else if(pContact->GetFullName() != "" && pTemp->GetFullName() == pContact->GetFullName())
								{
									isContactExist = TRUE;
									break;
								}
								else if(pContact->GetMobilePhone() != "" && pTemp->GetMobilePhone() == pContact->GetMobilePhone())
								{
									isContactExist = TRUE;
									break;
								}
								else if(pContact->GetHomePhone() != "" && pTemp->GetHomePhone() == pContact->GetHomePhone())
								{
									isContactExist = TRUE;
									break;
								}
								else if(pContact->GetBusinessPhone() != "" && pTemp->GetBusinessPhone() == pContact->GetBusinessPhone())
								{
									isContactExist = TRUE;
									break;
								}
							}

							if(isContactExist)
							{
								continue;
							}
						}														
						contactArray.Add(pContact);							
						contactCount++;							
					}
				}
				if(doLog)
					m_logHelper.LogPAB(L"Open Sub Contacts Folder");
				GetContacts(pSubFolder,folderCount,contactCount,skipCount,contactIndex,contactArray,doLog);
			}
			if(pageSize > 0)
			{
				if(contactCount == pageSize)
					break;								
			}
			if(m_pCtrl->IsPABSearchAbort())
				break;
			__recursionCount = 0;
		}
	}	
	if(doLog)
	{
		m_logHelper.LogPAB(L"------------------------------------");
		m_logHelper.LogPAB(L"Function GetPABCotacts END:");
		m_logHelper.LogPAB(L"------------------------------------");	
		m_logHelper.ClosePABLog();
	}
	__recursionCount = 0;
	RELEASE(lpMsgStoreTable);		

	if(folderCount == 0 && !m_pCtrl->IsPABSearchAbort())
	{
		error.code = 107;
		error.err = "TRContactFinder Cannot find private folders.";
		return FALSE;
	}

	return TRUE;
}
LPMAPIFOLDER CExMapi::GetContacts(LPMAPIFOLDER pFolder,LONG& folderCount,LONG& contactCount,LONG& skipCount,LONG& contactIndex,CObArray& contactArray,BOOL doLog)
{
	__recursionCount++;
	wchar_t buffer[5];
	_itow(__recursionCount,buffer,10);
	if(doLog)
	{
		if(__recursionCount > 1)
			m_logHelper.LogPAB(L"-------------------------------------");
		m_logHelper.LogPAB(L"Recursive Call No: "+CString(buffer));
		m_logHelper.LogPAB(L"-------------------------------------");
	}
	CString strFilterBy = m_pCtrl->GetPABSerachBy();
	CString strStartWith = m_pCtrl->GetPABSerachStartWith();
	strStartWith = strStartWith.MakeLower();
	ULONG pageSize;
	m_pCtrl->get_PABPageSize(&pageSize);
	LONG pageNumber = m_pCtrl->GetPABPageNumber();
	LONG startIndex = -1;
	if(pageSize>0)
	{
		startIndex = (pageSize * pageNumber) - pageSize;
	}

	LPMAPIFOLDER pSubFolder=NULL;
	LPMAPITABLE pHierarchy;
	CString strFolder;

	try
	{
		if(doLog)
			m_logHelper.LogPAB(L"RELEASE(m_pHierarchy); START");

		RELEASE(m_pHierarchy);
		
		if(doLog)
			m_logHelper.LogPAB(L"RELEASE(m_pHierarchy); END");

		if(doLog)
			m_logHelper.LogPAB(L"pHierarchy = GetHierarchy(pFolder); START");

		pHierarchy = GetHierarchy(pFolder);

		if(doLog)
			m_logHelper.LogPAB(L"pHierarchy = GetHierarchy(pFolder); END");

		if(pHierarchy) 
		{
			LPMAPIFOLDER pRecurse = NULL;
			do 
			{
				RELEASE(pSubFolder);
				m_pHierarchy = pHierarchy;			

				if(doLog)
					m_logHelper.LogPAB(L"pSubFolder = GetNextSubFolder(strFolder,pFolder); START");

				pSubFolder = GetNextSubFolder(strFolder,pFolder);

				if(doLog)
					m_logHelper.LogPAB(L"pSubFolder = GetNextSubFolder(strFolder,pFolder); END");
			
				if(pSubFolder) 
				{
					//if(strFolder == L"Deleted Items")
					//	continue;

					if(IsContactFolder(pSubFolder))
					{
						folderCount++;
	 					if(doLog)
							m_logHelper.LogPAB(L"if(GetContents(pSubFolder)) START");

						if(GetContents(pSubFolder))
						{
							if(doLog)
								m_logHelper.LogPAB(L"if(GetContents(pSubFolder)) END");

							SortContents(TABLE_SORT_ASCEND,PR_DISPLAY_NAME);
							//SortContents(TABLE_SORT_ASCEND,PR_SUBJECT);

							CString strText;
							CExMapiContact mapiContact;
							CString name;
							CString email;
							BOOL mustFilter = FALSE;
							mustFilter = strStartWith != "";
							
							if(doLog)
								m_logHelper.LogPAB(L"Start Reading Contact properties");

							while(GetNextContact(mapiContact) && !m_pCtrl->IsPABSearchAbort()) 
							{
								if(pageSize > 0)
								{
									if(contactCount == pageSize)
									{
										break;								
									}
								}

								contactIndex++;
								if(mustFilter)
								{
									if(strFilterBy == "Name")
									{
										mapiContact.GetName(name,PR_GIVEN_NAME);
										name = name.MakeLower();
										if(name.Find(strStartWith) != 0)				
										{
											continue;									
										}
									}

									if(strFilterBy == "Email")
									{
										mapiContact.GetEmail(email);
										email = email.MakeLower();
										if(email.Find(strStartWith) != 0)
										{
											continue;
										}
									}																
								}
								if(startIndex > 0 && skipCount < startIndex)
								{
									skipCount++;
									continue;								
								}

								CContact* pContact = new CContact();

								pContact->SetId(contactIndex);

								pContact->SetFolderName(strFolder);

								mapiContact.GetName(strText);
								pContact->SetFullName(strText);

								mapiContact.GetCompany(strText);
								pContact->SetCompany(strText);

								mapiContact.GetIMAddress(strText);
								pContact->SetIMAddress(strText);

								mapiContact.GetName(strText,PR_GIVEN_NAME);
								pContact->SetFirstName(strText);

								mapiContact.GetName(strText,PR_MIDDLE_NAME);
								pContact->SetMiddleName(strText);

								mapiContact.GetName(strText,PR_SURNAME);
								pContact->SetLastName(strText);

								mapiContact.GetEmail(strText);
								pContact->SetEmail(strText);	

								mapiContact.GetEmail(strText,2);//Email 2
								pContact->SetEmail2(strText);

								mapiContact.GetEmail(strText,3);//Email 3
								pContact->SetEmail3(strText);

								mapiContact.GetPhoneNumber(strText,PR_BUSINESS_TELEPHONE_NUMBER);
								pContact->SetBusinessPhone(strText);

								mapiContact.GetPhoneNumber(strText,PR_COMPANY_MAIN_PHONE_NUMBER);
								pContact->SetCompanyPhone(strText);

								mapiContact.GetPhoneNumber(strText,PR_BUSINESS_FAX_NUMBER);
								pContact->SetFax(strText);

								mapiContact.GetPhoneNumber(strText,PR_MOBILE_TELEPHONE_NUMBER);
								pContact->SetMobilePhone(strText);

								mapiContact.GetPhoneNumber(strText,PR_HOME_TELEPHONE_NUMBER);
								pContact->SetHomePhone(strText);

								if(m_pCtrl->FetchUnique())
								{
									BOOL isContactExist = FALSE;
									for(int i=0;i<contactArray.GetCount();i++)
									{
										CContact* pTemp = (CContact*)contactArray.GetAt(i);

										if(pContact->GetEmail() != "" && pTemp->GetEmail() == pContact->GetEmail())
										{
											isContactExist = TRUE;
											break;																	
										}
										else if(pContact->GetFullName() != "" && pTemp->GetFullName() == pContact->GetFullName())
										{
											isContactExist = TRUE;
											break;
										}
										else if(pContact->GetMobilePhone() != "" && pTemp->GetMobilePhone() == pContact->GetMobilePhone())
										{
											isContactExist = TRUE;
											break;
										}
										else if(pContact->GetHomePhone() != "" && pTemp->GetHomePhone() == pContact->GetHomePhone())
										{
											isContactExist = TRUE;
											break;
										}
										else if(pContact->GetBusinessPhone() != "" && pTemp->GetBusinessPhone() == pContact->GetBusinessPhone())
										{
											isContactExist = TRUE;
											break;
										}
									}

									if(isContactExist)
									{
										continue;
									}
								}														
								contactArray.Add(pContact);							
								contactCount++;							
							}
						}
					}

					m_pHierarchy = NULL; // so we don't release it in subsequent drilldown
					if(pageSize > 0)
					{
						if(contactCount == pageSize)
							break;								
					}
					
					if(__recursionCount < m_pCtrl->GetSubFOlderLevel())
					{
						pRecurse = GetContacts(pSubFolder,folderCount,contactCount,skipCount,contactIndex,contactArray,doLog);
					}
					if(pRecurse) 
					{
						RELEASE(pSubFolder);
						pSubFolder = pRecurse;
						break;
					}
				}
				else
				{
					__recursionCount = 1;
				}
				if(pageSize > 0)
				{
					if(contactCount == pageSize)
						break;								
				}

			} while(pSubFolder && !m_pCtrl->IsPABSearchAbort());
			RELEASE(pHierarchy);
			m_pHierarchy=NULL;
		}
		// this may occur many times depending on how deep the recursion is; make sure we haven't already assigned m_pFolder
		if(pSubFolder && m_pFolder!=pSubFolder) {
			RELEASE(m_pFolder);
			m_pFolder=pSubFolder;
		}
	}
	catch(_com_error &e)
	{
		if(doLog)
		{
			m_logHelper.LogPAB(L"GetContactFolderCount Exception Catch START:");
			m_logHelper.LogPAB(L"FolderName: " + strFolder );
			m_logHelper.LogPAB(e.ErrorMessage());
			m_logHelper.LogPAB(L"GetContactFolderCount Exception Catch END:");
		}
	}
	return pSubFolder;
} 
Example #17
0
void CDialogPlacePart::DoImportLibrary()
{
	CDraftDrawDoc *pDoc = theApp.GetActiveDocument();

	std::wstring sFilter = _T("External library file (*.xml)|*.xml||");//All Files (*.*)|*.*||;
	CStringArray saExtensions;
	saExtensions.Add(_T("xml"));

	CFileDialog fdialog(
		TRUE,		//save dialog box
		NULL,
		NULL,
		0,			//no flags
		sFilter.c_str(),
		NULL);

	if (fdialog.DoModal() == IDOK){

		//Get filename from dialog
		int offset = fdialog.m_ofn.nFileExtension;
		CString strFile = fdialog.m_ofn.lpstrFile;
		int nFilterIndex = fdialog.m_ofn.nFilterIndex;
		if ((!offset) || (fdialog.m_ofn.lpstrFile[offset] == 0)){

			strFile += _T(".") + saExtensions[fdialog.m_ofn.nFilterIndex - 1];
			sFilter = saExtensions[fdialog.m_ofn.nFilterIndex - 1];
		}

		//Try to import library
		CImporter *pImporter = new CImporter();
		CObArray *pObArray = new CObArray();
		pImporter->ImportLibrary(strFile, pObArray, pDoc->m_szGrid);

		//Create new library
		CString strLib = strFile.Left(strFile.ReverseFind('.'));
		if (strLib.ReverseFind(_T('\\')) >= 0){
			strLib = strLib.Right(strLib.GetLength() - strLib.ReverseFind(_T('\\')) - 1);
		}
		if (strLib.GetLength() == 0) strLib = strFile;
		DoInsertNewLibrary(strLib, TRUE);

		//Iterate all shapes to bounding rect union
		CRect rectUnion;
		for (int i = 0; i < pObArray->GetSize(); i++){
			CShapeUnit *pSh = (CShapeUnit *)pObArray->GetAt(i);
			CRect rect;
			pSh->GetRectTemp(rect);

			TRACE(_T("Importing part %s.\n"),(LPCTSTR)(pSh->m_sUnitName));

			//rectUnion.UnionRect(rectUnion, rect);
			if (rect.Width()>rectUnion.Width()){
				rectUnion = CRect(CPoint(0, 0), CSize(rect.Width(), rectUnion.Height()));
			}
			if (rect.Height()>rectUnion.Height()){
				rectUnion = CRect(CPoint(0, 0), CSize(rectUnion.Width(), rect.Height()));
			}
		}

		//rectUnion.InflateRect(DCABLE_PADDINGX_DEFAULT << 1, DCABLE_PADDINGY_DEFAULT << 1);
		rectUnion.InflateRect(DCABLE_GRIDX_DEFAULT, DCABLE_GRIDY_DEFAULT);
		CSize size=rectUnion.Size();
		rectUnion = CRect(CPoint(0, 0), rectUnion.Size());

		//Insert/update parts
		for (int i = 0; i<pObArray->GetSize(); i++){

			//Insert part
			CShapeUnit *pSh = (CShapeUnit *)pObArray->GetAt(i);

			//Do insert in librarry
			DoInsertPart(pSh->m_sUnitName);

			//Get bounding rect
			CRect rectTemp;
			pSh->GetRectTemp(rectTemp);
			((CShapeFrmRect*)pSh->m_obarrShapearr[0])->m_Rect = rectUnion;
			CPoint offset = CPoint((rectUnion.Width() - rectTemp.Width()) >> 1, (rectUnion.Height() - rectTemp.Height()) >> 1);

			//Call a method to normalize ShapeUnit from bounding rect TopLeft to (0,0) or any other offset
			//pSh->NormalizeChildShapes(CPoint(DCABLE_PADDINGX_DEFAULT, DCABLE_PADDINGY_DEFAULT));
			pSh->NormalizeChildShapes(offset);

			//Save parts
			//Create new method in CDocument to be called from here and serialize the parts
			CString strFile = pSh->m_sUnitName;
			//Keep previous part edition status
			BOOL bFlagPartEdit = pDoc->m_bFlagPartEdit;
			//Set part edition mode to save the save
			pDoc->m_bFlagPartEdit = TRUE;
			CObArray* prevObArray = pDoc->m_pObArray;
			pDoc->m_pObArray = &pSh->m_obarrShapearr;
			pDoc->OnDatabaseSave(strLib + _T(".") + strFile);
			pDoc->m_pObArray = prevObArray;
			//Restore flag
			pDoc->m_bFlagPartEdit = bFlagPartEdit;
		}

	}//End dialog result OK