Exemple #1
0
void BuildLibPath( void )
{
	Handle searchPath;
	
	// make the search path handle 
	// and fill it with the initial search path
	// use strlen neat so as to chop off trailing null!
	searchPath = NewHandle( strlen( INITIAL_SEARCH_PATH ) );
	if( (searchPath != NULL) && ( ResError() == noErr ) )
	{
		HLock( searchPath );
			BlockMove( INITIAL_SEARCH_PATH, *searchPath, strlen( INITIAL_SEARCH_PATH  ) );
		HUnlock( searchPath );
			
		// Try to get the application support folder
		FindFolderPath( searchPath, kApplicationSupportFolderType, FOLDER_SEARCH_PATH );
		
		// Try to get the extensions folder
		FindFolderPath( searchPath, kExtensionFolderType, FOLDER_SEARCH_PATH  );
		
		// lock it out of the way, 
		// null terminate it, overwriting the last \t, making a c string
		// and set LIBDIR to it
		HLockHi( searchPath );
		(*searchPath)[ GetHandleSize( searchPath ) -1 ] = '\0';
		LIBDIR = *searchPath;
	}
}
Exemple #2
0
void MAPIFolder::Initialize(LPMAPIFOLDER pFolder, LPTSTR displayName, LPSBinary pEntryId)
{
	HRESULT hr=S_OK;
    if (m_folder != NULL)
        UlRelease(m_folder);
    if (m_EntryID.lpb != NULL)
        FreeEntryID(m_EntryID);
	if(m_pContentsTable != NULL)
		UlRelease(m_pContentsTable);
	if(m_pHierarchyTable!=NULL)
		UlRelease(m_pHierarchyTable);

    m_folder = pFolder;
    m_displayname = displayName;    
    
    //replace later by "/" allow "/"
	/*
    size_t npos= m_displayname.find(L"/");
    if ((npos != std::wstring::npos) && (npos>0))
    {
        m_displayname.replace(npos,1,CONST_FORWDSLASH);
    }
	*/
	//parse whole string for forward slash not just one occurence
	std::wstring::size_type i = m_displayname.find(L"/");
	while (i != std::wstring::npos && i < m_displayname.size())
    {
        m_displayname.replace(i, wcslen(L"/"),CONST_FORWDSLASH);
        i +=  wcslen(L"/");

        i = m_displayname.find( L"/", i);
    }

    CopyEntryID(*pEntryId, m_EntryID);
	
	//Get folder hierarchy table
	if (FAILED(hr = m_folder->GetHierarchyTable(fMapiUnicode, &m_pHierarchyTable)))
    {
        throw MAPIFolderException(E_FAIL, L"GetFolderIterator(): GetHierarchyTable Failed.",
            ERR_MAPI_FOLDER, __LINE__, __FILE__);
    }
	
	try{
		//get folders content tabel
		if (FAILED(hr = m_folder->GetContentsTable(fMapiUnicode, &m_pContentsTable)))
		{
			throw MAPIFolderException(hr, L"Initialize(): GetContentsTable Failed.",
				ERR_MAPI_FOLDER, __LINE__, __FILE__);
		}    
	}
	catch(...)
	{
		throw MAPIFolderException(hr, L"Initialize(): GetContentsTable Failed.",
            ERR_MAPI_FOLDER, __LINE__, __FILE__);
	}

	ULONG ulItemMask =ZCM_ALL;
	//disable restriction for only mails on IPF.Note folders.
	//Lets migrate everything in it for now.
/*
	//find container class	
    wstring wstrCntrClass = L"";
    if(S_OK==ContainerClass(wstrCntrClass))
    {
        if (_tcsicmp(wstrCntrClass.c_str(), _TEXT("IPF.NOTE")) == 0)
            ulItemMask = ZCM_MAIL;
    }    
*/
	//Apply restrictions.
	Zimbra::MAPI::MIRestriction restriction;
	FILETIME tmpTime = { 0, 0 };
	if (FAILED(hr = m_pContentsTable->Restrict(restriction.GetRestriction(ulItemMask, tmpTime), 0)))
    {
        throw MAPIFolderException(hr, L"MAPIFolder::Initialize():Restrict Failed.",
            ERR_MAPI_FOLDER, __LINE__, __FILE__);
    }

    if (m_session)
    {
        wstring wstrFolderPath = FindFolderPath();
        m_folderpath = wstrFolderPath;
    }
}