xptiInterfaceEntry*
xptiTypelibGuts::GetEntryAt(PRUint16 i)
{
    static const nsID zeroIID =
        { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } };

    NS_ASSERTION(mHeader, "bad state");
    NS_ASSERTION(i < GetEntryCount(), "bad index");

    xptiInterfaceEntry* r = mEntryArray[i];
    if (r)
        return r;

    XPTInterfaceDirectoryEntry* iface = mHeader->interface_directory + i;

    xptiWorkingSet* set =
        xptiInterfaceInfoManager::GetSingleton()->GetWorkingSet();

    if (iface->iid.Equals(zeroIID))
        r = set->mNameTable.Get(iface->name);
    else
        r = set->mIIDTable.Get(iface->iid);

    if (r)
        SetEntryAt(i, r);

    return r;
}
Beispiel #2
0
MEMBERID PASCAL CCmdTarget::MemberIDFromName(
	const AFX_DISPMAP* pDispMap, LPCTSTR lpszName)
{
	// search all maps and their base maps
	UINT nInherit = 0;
	while (pDispMap != NULL)
	{
		// search all entries in this map
		const AFX_DISPMAP_ENTRY* pEntry = pDispMap->lpEntries;
		UINT nEntryCount = GetEntryCount(pDispMap);
		for (UINT nIndex = 0; nIndex < nEntryCount; nIndex++)
		{
			if (pEntry->vt != VT_MFCVALUE &&
				lstrcmpi(pEntry->lpszName, lpszName) == 0)
			{
				if (pEntry->lDispID == DISPID_UNKNOWN)
				{
					// the MEMBERID is combination of nIndex & nInherit
					ASSERT(MAKELONG(nIndex+1, nInherit) != DISPID_UNKNOWN);
					return MAKELONG(nIndex+1, nInherit);
				}
				// the MEMBERID is specified as the lDispID
				return pEntry->lDispID;
			}
			++pEntry;
		}
#ifdef _AFXDLL
		pDispMap = (*pDispMap->pfnGetBaseMap)();
#else
		pDispMap = pDispMap->pBaseMap;
#endif
		++nInherit;
	}
	return DISPID_UNKNOWN;  // name not found
}
void TestRemoveWhenUnderlyingDataExists()
{
    std::cout << "PrintDataDirectoryUT TestRemoveWhenUnderlyingDataExists" << std::endl;
   
    // To verify that the data is actually removed, the test checks for an empty parent directory
    // Create a child directory so a known parent directory exists
    std::string dataDir = testDataDir + "/dataDir";
    mkdir(dataDir.c_str(), 0755);
    
    Copy("resources/slices/slice_1.png", dataDir);
   
    PrintDataDirectory printData(dataDir);

    if (!printData.Remove())
    {
        std::cout << "%TEST_FAILED% time=0 testname=TestRemoveWhenUnderlyingDataExists (PrintDataDirectoryUT) "
                << "message=Expected Remove to return true, got false" << std::endl;
        mainReturnValue = EXIT_FAILURE;
        return;
    }

    // Verify that the directory no longer exists
    if (GetEntryCount(testDataDir, DT_DIR) != 0)
    {
        std::cout << "%TEST_FAILED% time=0 testname=TestRemoveWhenUnderlyingDataExists (PrintDataDirectoryUT) "
                << "message=Expected Remove to remove print data, directory still present" << std::endl;
        mainReturnValue = EXIT_FAILURE;
        return;
    }
}
TVerdict CPerformance422Step::doTestStepPostambleL()
	{

	if(iProfile)
		{
		Profiler::Stop();
		Profiler::Close();
		Profiler::Unload();	
		}
	
	TInt frequency;
	HAL::Get(HAL::EFastCounterFrequency, frequency);	
	iDuration=(TReal64)(iStopCount-iStartCount)/frequency;
	
	INFO_PRINTF2(_L("Elaped time = %f seconds."),iDuration);	
	//get entry count
	TInt entryCount=GetEntryCount();
	INFO_PRINTF2(_L("Fetched %d email(s)."),entryCount);	
	
	if(entryCount==1)
		{
		return EPass;	
		}
	else
		{
		return EFail;		
		}

	}
Beispiel #5
0
//************************************************************************
// adds an entry to the list
//************************************************************************
CListItem<CEventLogEntry*> *CEventLog::AddItem(CEventLogEntry *pEntry)
{
	CListItem<CEventLogEntry*> *pItem = CLCDList<CEventLogEntry*>::AddItem(pEntry);
	if(GetEntryCount() > CConfig::GetIntSetting(NOTIFY_LOGSIZE))
		RemoveItem(((CListItem<CEventLogEntry*>*)GetFirstEntry())->GetItemData());
	
	if(GetTickCount() - m_dwLastScroll > 10000)
		SetPosition(pItem);
	return pItem;
}
void CStatisticForm::OnTimer(UINT_PTR id)
{
	if (!IsWindowVisible())		// no point doing this updating if form not shown
		return;

	switch (id) {
	case 0:
		{
            FreeCachedStatisticEntry();
            m_listCtrl.SetItemCountEx(GetEntryCount(false), LVSICF_NOSCROLL);
		}
		break;
	}
}
Beispiel #7
0
bool ListInterface::MoveSelectedEntry(const wxString &group, int direction)
{
	const DataEntry *selected = GetSelectedEntry(group);

	if( !selected )
		return false;

	List *list = FindListByName(group);
	int itemid = list->GetSelectedIndex();
	
	//Move List Index
	if( !list->MoveIndex(itemid, direction) )
		return false;

	int selectedEntryIndex = -1;
	for( unsigned int i = 0; i < GetEntryCount(); ++i )
	{
		const DataEntry* entry = data[i];

		if( entry )
		{
			if( entry->CompareName(selected->GetName()) )
			{
				selectedEntryIndex = i;
				break;
			}
		}
	}

	//Swap selection and its victim
	if( selectedEntryIndex != -1 )
	{
		int swapIndex = selectedEntryIndex + (direction < 0 ? -1 : 1); 

		if( swapIndex < 0 || swapIndex >= (int)data.size() )
		{
			return false;
		}

		DataEntry *selectedEntry = data[selectedEntryIndex];
		DataEntry *swapEntry = data[swapIndex];
		
		data[selectedEntryIndex] = swapEntry;
		data[swapIndex] = selectedEntry;
	}

	return true;
}
Beispiel #8
0
//returns the index of the area owning this link
unsigned int WorldMap::WhoseLinkAmI(int link_index) const
{
	unsigned int cnt = GetEntryCount();
	for (unsigned int i = 0; i < cnt; i++) {
		WMPAreaEntry *ae=area_entries[i];
		for (int direction=0;direction<4;direction++)
		{
			int j=ae->AreaLinksIndex[direction];
			if (link_index>=j) {
				j+=ae->AreaLinksCount[direction];
				if(link_index<j) {
					return i;
				}
			}
		}
	}
	return (ieDword) -1;
}
Beispiel #9
0
const AFX_DISPMAP_ENTRY* PASCAL CCmdTarget::GetDispEntry(MEMBERID memid)
{
	const AFX_DISPMAP* pDerivMap = GetDispatchMap();
	const AFX_DISPMAP* pDispMap;
	const AFX_DISPMAP_ENTRY* pEntry;

	if (memid == DISPID_VALUE)
	{
		// DISPID_VALUE is a special alias (look for special alias entry)
		pDispMap = pDerivMap;
		while (pDispMap != NULL)
		{
			// search for special entry with vt == VT_MFCVALUE
			pEntry = pDispMap->lpEntries;
			while (pEntry->nPropOffset != -1)
			{
				if (pEntry->vt == VT_MFCVALUE)
				{
					memid = pEntry->lDispID;
					if (memid == DISPID_UNKNOWN)
					{
						// attempt to map alias name to member ID
						memid = MemberIDFromName(pDerivMap, pEntry->lpszName);
						if (memid == DISPID_UNKNOWN)
							return NULL;
					}
					// break out and map the member ID to an entry
					goto LookupDispID;
				}
				++pEntry;
			}
#ifdef _AFXDLL
			pDispMap = (*pDispMap->pfnGetBaseMap)();
#else
			pDispMap = pDispMap->pBaseMap;
#endif
		}
	}

LookupDispID:
	if ((long)memid > 0)
	{
		// find AFX_DISPMAP corresponding to HIWORD(memid)
		UINT nTest = 0;
		pDispMap = pDerivMap;
		while (pDispMap != NULL && nTest < (UINT)HIWORD(memid))
		{
#ifdef _AFXDLL
			pDispMap = (*pDispMap->pfnGetBaseMap)();
#else
			pDispMap = pDispMap->pBaseMap;
#endif
			++nTest;
		}
		if (pDispMap != NULL)
		{
			UINT nEntryCount = GetEntryCount(pDispMap);
			if ((UINT)LOWORD(memid) <= nEntryCount)
			{
				pEntry = pDispMap->lpEntries + LOWORD(memid)-1;

				// must have automatic DISPID or same ID
				// if not then look manually
				if (pEntry->lDispID == DISPID_UNKNOWN ||
					pEntry->lDispID == memid)
				{
					return pEntry;
				}
			}
		}
	}

	// second pass, look for DISP_XXX_ID entries
	pDispMap = pDerivMap;
	while (pDispMap != NULL)
	{
		// find AFX_DISPMAP_ENTRY where (pEntry->lDispID == memid)
		pEntry = pDispMap->lpEntries;
		while (pEntry->nPropOffset != -1)
		{
			if (pEntry->lDispID == memid)
				return pEntry;

			++pEntry;
		}
		// check base class
#ifdef _AFXDLL
		pDispMap = (*pDispMap->pfnGetBaseMap)();
#else
		pDispMap = pDispMap->pBaseMap;
#endif
	}

	return NULL;    // no matching entry
}
void TestMoveWhenDestinationDirectoryExists()
{
    std::cout << "PrintDataDirectoryUT TestMoveWhenDestinationDirectoryExists" << std::endl;

    // To verify that the data is actually moved, the test checks for an empty parent directory
    // Create a child directory so a known parent directory exists
    std::string dataDir = testDataDir + "/dataDir";
    mkdir(dataDir.c_str(), 0755);
    
    Copy("resources/slices/slice_1.png", dataDir);
    Copy("resources/slices/slice_2.png", dataDir);
    Copy("resources/good_settings", dataDir + "/printsettings");
   
    PrintDataDirectory printData(dataDir);

    if (!printData.Move(testPrintDataDir))
    {
        std::cout << "%TEST_FAILED% time=0 testname=TestMoveWhenDestinationDirectoryExists (PrintDataDirectoryUT) "
                << "message=Expected Move to return true, got false" << std::endl;
        mainReturnValue = EXIT_FAILURE;
        return;
    }

    // Look for the print data directory in its new location
    DIR* printDataDir = opendir(testPrintDataDir.c_str());
    std::string newPath;
    struct dirent* entry = readdir(printDataDir);
    
    while (entry != NULL)
    {
        if (entry->d_type == DT_DIR && std::string(entry->d_name) != "." && std::string(entry->d_name) != "..")
        {
            std::ostringstream ss;
            ss << testPrintDataDir << "/" << entry->d_name;
            newPath = ss.str();
        }
        entry = readdir(printDataDir);
    }
    
    closedir(printDataDir);

    // Old directory no longer contains print data
    if (GetEntryCount(testDataDir, DT_DIR) != 0)
    {
        std::cout << "%TEST_FAILED% time=0 testname=TestMoveWhenDestinationDirectoryExists (PrintDataDirectoryUT) "
                << "message=Expected Move to remove print data from previous parent directory, directory still "
                << "present" << std::endl;
        mainReturnValue = EXIT_FAILURE;
        return;
    }

    // Specified destination contains print data
    std::string slice1 = newPath + "/slice_1.png";
    std::string slice2 = newPath + "/slice_2.png";
    std::string printSettings = newPath + "/printsettings";
    if (!std::ifstream(slice1.c_str()) || !std::ifstream(slice2.c_str()) || !std::ifstream(printSettings.c_str()))
    {
        std::cout << "%TEST_FAILED% time=0 testname=TestMoveWhenDestinationDirectoryExists (PrintDataDirectoryUT) "
                << "message=Expected destination directory to contain print data, all print data not present"
                << std::endl;
        mainReturnValue = EXIT_FAILURE;
        return;
    }

    // Verify that PrintData instance knows where its data resides after moving
    int expectedLayerCount = 2;
    int actualLayerCount = printData.GetLayerCount();
    if (expectedLayerCount != actualLayerCount)
    {
        std::cout << "%TEST_FAILED% time=0 testname=TestCreateFromNewDataWhenDownloadDirectoryContainsTarGzFile (PrintDataDirectoryUT) "
                << "message=Layer count incorrect after moving print data, expected "
                << expectedLayerCount << ", got " << actualLayerCount << std::endl;
        mainReturnValue = EXIT_FAILURE;
        return;
    }
}
void CStatisticForm::OnExportClick()
{
	CString	fileFilter;
	CString	filename;

	fileFilter = _T("CSV Files (*.csv)|*.csv|All Files (*.*)|*.*|");

	CFileDialog dlg(FALSE,_T("statistics"),NULL,OFN_OVERWRITEPROMPT|OFN_ENABLESIZING|OFN_PATHMUSTEXIST,fileFilter);
    INT_PTR ret = dlg.DoModal();

	filename = dlg.GetPathName();
	if (ret == IDOK)
    {
		CPath path(filename);
		if (path.GetExtension() == _T(""))
        {
			path.AddExtension(_T(".csv"));
			filename = CString(path);
		}

        CFile file(filename, CFile::modeCreate|CFile::modeWrite);
        CString csvSep = GetCsvSeparator();

        // Output header
        CString row = _T("");
        for(int field=0; field < 7; field++)
        {
            LVCOLUMN column = { 0 };
            column.mask = LVCF_TEXT;
            column.cchTextMax = 100;
            column.pszText = new TCHAR[column.cchTextMax];
            m_listCtrl.GetColumn(field, &column);

            if (field > 0)
                row.Append(csvSep);
            row.Append(column.pszText);

            delete [] column.pszText;
        }
        row.Append(_T("\n"));
        CT2CA outputHeaderText(row, CP_UTF8);
        file.Write(outputHeaderText, (DWORD) ::strlen(outputHeaderText));

        // Output data
        const LONG entryCount = GetEntryCount(false);
        for(LONG i = 0; i<entryCount; i++)
        {
            row = _T("");
            for(int field=0; field<7; field++)
            {
                if (field > 0)
                    row.Append(csvSep);
                row.Append(GetEntryString(i,field));
            }
            row.Append(_T("\n"));

            CT2CA outputText(row, CP_UTF8);
            file.Write(outputText, (DWORD) ::strlen(outputText));
        }
    }
}
void CStatisticForm::OnResetClick()
{
    FreeCachedStatisticEntry();
    m_listCtrl.SetItemCountEx(GetEntryCount(true), LVSICF_NOSCROLL);
}
void CStatisticForm::OnFilterMapperClick()
{
	show_filter_mapper = !show_filter_mapper;
    FreeCachedStatisticEntry();
    m_listCtrl.SetItemCountEx(GetEntryCount(false), LVSICF_NOSCROLL);
}
/*----------------------------------------------------------------------
|   PLT_FileMediaServer::BuildFromFilePath
+---------------------------------------------------------------------*/
PLT_MediaObject*
PLT_FileMediaServer::BuildFromFilePath(const NPT_String& filepath, 
                                       bool              with_count /* = true */,
                                       NPT_SocketInfo*   info /* = NULL */,
                                       bool              keep_extension_in_title /* = false */)
{
    NPT_String            delimiter = m_DirDelimiter;
    NPT_String            root = m_Path;
    PLT_MediaItemResource resource;
    PLT_MediaObject*      object = NULL;
    int                   dir_delim_index;

    /* make sure this is a valid entry */
    /* and retrieve the entry type (directory or file) */
    NPT_DirectoryEntryInfo entry_info; 
    if (!ProceedWithEntry(filepath, entry_info)) goto failure;

    /* find the last directory delimiter */
    dir_delim_index = filepath.ReverseFind(delimiter);
    if (dir_delim_index < 0) goto failure;

    if (entry_info.type == NPT_FILE_TYPE) {
        object = new PLT_MediaItem();

        /* we need a valid extension to retrieve the mimetype for the protocol info */
        int ext_index = filepath.ReverseFind('.');
        if (ext_index <= 0 || ext_index < dir_delim_index) {
            ext_index = filepath.GetLength();
        }

        /* Set the title using the filename for now */
        object->m_Title = filepath.SubString(dir_delim_index+1, 
            keep_extension_in_title?filepath.GetLength():ext_index - dir_delim_index -1);
        if (object->m_Title.GetLength() == 0) goto failure;

        /* Set the protocol Info from the extension */
        const char* ext = ((const char*)filepath) + ext_index;
        resource.m_ProtocolInfo = PLT_MediaItem::GetProtInfoFromExt(ext);
        if (resource.m_ProtocolInfo.GetLength() == 0)  goto failure;

        /* Set the resource file size */
        resource.m_Size = entry_info.size;
 
        /* format the resource URI */
        NPT_String url = filepath.SubString(root.GetLength());

        // get list of ip addresses
        NPT_List<NPT_String> ips;
        NPT_CHECK_LABEL_SEVERE(PLT_UPnPMessageHelper::GetIPAddresses(ips), failure);

        // if we're passed an interface where we received the request from
        // move the ip to the top
        if (info && info->local_address.GetIpAddress().ToString() != "0.0.0.0") {
            ips.Remove(info->local_address.GetIpAddress().ToString());
            ips.Insert(ips.GetFirstItem(), info->local_address.GetIpAddress().ToString());
        }

        // iterate through list and build list of resources
        NPT_List<NPT_String>::Iterator ip = ips.GetFirstItem();
        while (ip) {
            NPT_HttpUrl uri = m_FileBaseUri;
            NPT_HttpUrlQuery query;
            query.AddField("path", url);
            uri.SetHost(*ip);
            uri.SetQuery(query.ToString());
            //uri.SetPath(uri.GetPath() + url);

            /* prepend the base URI and url encode it */ 
            //resource.m_Uri = NPT_Uri::Encode(uri.ToString(), NPT_Uri::UnsafeCharsToEncode);
            resource.m_Uri = uri.ToString();

            /* Look to see if a metadatahandler exists for this extension */
            PLT_MetadataHandler* handler = NULL;
            NPT_Result res = NPT_ContainerFind(m_MetadataHandlers, PLT_MetadataHandlerFinder(ext), handler);
            if (NPT_SUCCEEDED(res) && handler) {
                /* if it failed loading data, reset the metadatahandler so we don't use it */
                if (NPT_SUCCEEDED(handler->LoadFile(filepath))) {
                    /* replace the title with the one from the Metadata */
                    NPT_String newTitle;
                    if (handler->GetTitle(newTitle) != NULL) {
                        object->m_Title = newTitle;
                    }

                    /* assign description */
                    handler->GetDescription(object->m_Description.long_description);

                    /* assign album art uri if we haven't yet */
                    /* prepend the album art base URI and url encode it */ 
                    if (object->m_ExtraInfo.album_art_uri.GetLength() == 0) {
                        NPT_HttpUrl uri = m_AlbumArtBaseUri;
                        NPT_HttpUrlQuery query;
                        query.AddField("path", url);
                        uri.SetHost(*ip);
                        uri.SetQuery(query.ToString());
                        //uri.SetPath(uri.GetPath() + url);

                        object->m_ExtraInfo.album_art_uri = NPT_Uri::PercentEncode(uri.ToString(), NPT_Uri::UnsafeCharsToEncode);
                    }

                    /* duration */
                    handler->GetDuration((NPT_UInt32&)resource.m_Duration);

                    /* protection */
                    handler->GetProtection(resource.m_Protection);
                }
            }

            object->m_ObjectClass.type = PLT_MediaItem::GetUPnPClassFromExt(ext);
            object->m_Resources.Add(resource);

            ++ip;
        }
    } else {
        object = new PLT_MediaContainer;

        /* Assign a title for this container */
        if (filepath.Compare(root, true) == 0) {
            object->m_Title = "Root";
        } else {
            object->m_Title = filepath.SubString(dir_delim_index+1, filepath.GetLength() - dir_delim_index -1);
            if (object->m_Title.GetLength() == 0) goto failure;
        }

        /* Get the number of children for this container */
        if (with_count) {
            NPT_Cardinal count = 0;
            NPT_CHECK_LABEL_SEVERE(GetEntryCount(filepath, count), failure);
            ((PLT_MediaContainer*)object)->m_ChildrenCount = count;
        }

        object->m_ObjectClass.type = "object.container";
    }

    /* is it the root? */
    if (filepath.Compare(root, true) == 0) {
        object->m_ParentID = "-1";
        object->m_ObjectID = "0";
    } else {
        /* is the parent path the root? */
        if (dir_delim_index == (int)root.GetLength() - 1) {
            object->m_ParentID = "0";
        } else {
            object->m_ParentID = "0" + delimiter + filepath.SubString(root.GetLength(), dir_delim_index - root.GetLength());
        }
        object->m_ObjectID = "0" + delimiter + filepath.SubString(root.GetLength());
    }

    return object;

failure:
    delete object;
    return NULL;
}