Ejemplo n.º 1
0
BOOL CPictureSizeDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
   for(int i = 0; i<NUM_OF_UNITS; i++)
   {
      m_cbWidthUnits.AddString(aUnitsStrings[i]);
      m_cbHeightUnits.AddString(aUnitsStrings[i]);
   }

   
   CPtrList SelItems;
   m_pVecTstView->GetSelectedItems(SelItems, TRUE);
   CVecContainer::ArrangeItemsForTrack(SelItems);
   POSITION pos = SelItems.GetHeadPosition();
   while(pos!=NULL)
   {
      CVecBase* pVec = (CVecBase*)SelItems.GetNext(pos);;

      CDRect rect;
      rect = pVec->GetRect();
      m_dPicVecWidth = m_dOriginalPicVecWidth = rect.right - rect.left;
      m_dPicVecHeight = m_dOriginalPicVecHeight = rect.bottom - rect.top;

      UpdateData(FALSE);
      break;//initiate the dialog with the data of the first text item
   }

   FillWidthAndHeight();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 2
0
void COwnedLostItem::SetHandledViaNetscape()
{
	m_nHandleMethod = OL_OTHER_APP;

	// Get the app's name.
	CString netscapeName;
	char buffer[_MAX_PATH+1];
	::GetModuleFileName(theApp.m_hInstance, buffer, _MAX_PATH);
	char *pSlash = ::strrchr(buffer, '\\');
	netscapeName = (char*)(pSlash+1);
	netscapeName.MakeUpper();

	// Get the app's directory. Adequate heuristic for version-checking Netscape
	CString directoryName(buffer);
	directoryName.MakeUpper();

	// Special Internet Shortcut check
	if (IsInternetShortcut())
	{
		CInternetShortcut internetShortcut;
		if (!internetShortcut.ShellSupport())
		{
			m_nHandleMethod = OL_CURRENT_NETSCAPE;
			return;
		}
		
		CString fileClass = GetInternetShortcutFileClass();
		SetHandleMethodViaFileClass(fileClass, netscapeName, directoryName);
		return;
	}

	CPtrList* allHelpers = &(CHelperApp::m_cplHelpers);

	for (POSITION pos = allHelpers->GetHeadPosition(); pos != NULL;)
	{
		CHelperApp* app = (CHelperApp*)allHelpers->GetNext(pos);
		CString helperMime(app->cd_item->ci.type);

		if (helperMime == m_csMimeType)
		{
			// Found the helper app.  See if Netscape is truly handling this mime type.
			CString fileClass(app->strFileClass);

			if (fileClass != "")
			{
				SetHandleMethodViaFileClass(fileClass, netscapeName, directoryName);
				return;
			}
			else m_bBroken = TRUE; // Treat as if ignored. Don't want to pop up a dialog over this.

			if (app->how_handle == HANDLE_VIA_NETSCAPE)
				m_nHandleMethod = OL_CURRENT_NETSCAPE;
			else m_nHandleMethod = OL_OTHER_APP;

			return;
		}
	}

	m_bBroken = TRUE; // Didn't even find this mime type. Don't want to fool with it.
}
Ejemplo n.º 3
0
BOOL CPicTransparentDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	CString strColorHex;
   CPtrList SelItems;
   m_pVecTstView->GetSelectedItems(SelItems);
   POSITION pos = SelItems.GetHeadPosition();
   while(pos!=NULL)
   {
      CVecBase* pVec = (CVecBase*)SelItems.GetNext(pos);
      CVecBitmapBase* pBitmapBase = dynamic_cast<CVecBitmapBase*>(pVec);
      if(pBitmapBase!=NULL)
      {
         m_bIsTransparent = pBitmapBase->IsTransparent();

		  m_clrTransparent = pVec->GetShadowColor();
		  strColorHex.Format("Color: #%06X",m_clrTransparent);
		  m_ColorPickerButton.SetWindowText(strColorHex);

         break;
      }
   }

   UpdateData(FALSE);
   OnIsTransparent();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 4
0
int
CGenethonDoc::AppendDataRows(CPtrList& SequenceList, int Append )
{

	int SkippedName = 0;
	POSITION tPos = SequenceList.GetHeadPosition();
	while ( tPos != NULL ) {

		SeqNameStruct *tSNS = (SeqNameStruct *)SequenceList.GetNext(tPos);

		int DupName = 0;

		POSITION testPos = pGSFiller->SegDataList.GetHeadPosition();
		while (testPos != NULL ) {
			CGeneSegment *tCGSeg = (CGeneSegment *)pGSFiller->SegDataList.GetNext(testPos);
			if ( tCGSeg->GetTitle() == tSNS->Name ) {
				DupName = 1;
				break;
			}
		}
		
		if ( DupName ) {
			SkippedName = 1;
			delete tSNS;
			continue;
		}
		
		CGeneSegment *tCGSeg = new CGeneSegment();

		if ( tCGSeg == 0 ) {
			AfxMessageBox("GetMSFFile:new Fail 4" );
			delete pGSFiller;
			pGSFiller = NULL;
			return 0;
		}

		if ( !tCGSeg->Create( LINESEQUENCE, tSNS->Name, tSNS->Descr, tSNS->Weight, tSNS->hText, tSNS->Len, tSNS->Start, &m_UserVars.m_ForeColor, &m_UserVars.m_BackColor ) ) {
			AfxMessageBox("GetMSFFile:Create Fail 2" );
			delete pGSFiller;
			pGSFiller = NULL;
			return 0;
		}			
		
		// Cleanup
		delete tSNS;

		// put it on the list
		pGSFiller->AddData( tCGSeg );
		

	}

	if ( SkippedName ) {
		AfxMessageBox( "Duplicate Sequences (Names) have been discarded!" );
	}

	return 1;
}
Ejemplo n.º 5
0
BOOL CUpdateUtil::CompareFileVersion(CItemList* pItemListSourceCmp, CItemList* pItemListDestCmp)
{
//	UPDATE_DATA* tmpClientSection = NULL;
//	UPDATE_DATA* tmpServerSection = NULL;

//	memset(tmpClientSection, 0, sizeof(UPDATE_DATA));
//	memset(tmpServerSection, 0, sizeof(UPDATE_DATA));
	
	CPtrList* pPLClient = pItemListDestCmp->GetPtrList();
	CPtrList* pPLServer = pItemListSourceCmp->GetPtrList();
	BOOL bExist = FALSE;
	UPDATE_DATA *psiServer = NULL;
	UPDATE_DATA *psiClient = NULL;
	CString strFilePath = "";

	UTIL_CANCEL();
	if(pPLClient->GetCount() == 0)
	{
		// Server xml File check
		POSITION posServer= pPLServer->GetHeadPosition();
		psiServer = NULL;
		strFilePath = "";
		while(posServer)
		{	
			bExist = FALSE;

			psiServer = (UPDATE_DATA *)pPLServer->GetNext(posServer);
			strFilePath.Format("%s\\%s", psiServer->DownPath, psiServer->Name);

			switch (VersionCheck(strFilePath, "0", psiServer->Version, psiServer->DownURL, psiServer->CheckSum, psiServer->Size))
			{
			case UPDATE_FLAG_NORMAL:
				TRACE("%s File : Do not anything  because %s == %s\n", strFilePath, psiServer->Version, psiServer->Version);
				psiServer->UpdateFlag = UPDATE_FLAG_NORMAL;
				break;
			case UPDATE_FLAG_NEW:
				TRACE("%s File : New  because not exsist\n", strFilePath);
				psiServer->UpdateFlag = UPDATE_FLAG_NEW;
				break;
			case UPDATE_FLAG_UPDATE:
				TRACE("%s File : Update  because %s < %s\n", strFilePath, psiServer->Version, psiServer->Version);
				psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
				break;
			case UPDATE_FLAG_DIFFERENT:
				TRACE("%s File : Update because different between xml version file and exist file\n", strFilePath);
				psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
				break;
			}
		}
	}
	else
	{
		return	CompareFileVersion2(pItemListSourceCmp, pItemListDestCmp);
	}

	return TRUE;
}
Ejemplo n.º 6
0
void CPictureSizeDlg::Apply() 
{
   if(m_dLastHeight == m_dHeight && m_dLastWidth == m_dWidth && 
      m_iLastHeightUnits == m_iHeightUnits && m_iLastWidthUnits == m_iWidthUnits)
   return;

   CPtrList SelItems;
   m_pVecTstView->GetSelectedItems(SelItems, TRUE);
   CVecContainer::ArrangeItemsForTrack(SelItems);
   POSITION pos = SelItems.GetHeadPosition();
   m_pVecTstView->m_VecController.m_UndoManager.CreateNewStep();
   while(pos!=NULL)
   {
      CVecBase* pVec = (CVecBase*)SelItems.GetNext(pos);;
      m_pVecTstView->m_VecController.m_UndoManager.AddActionToLastStep(pVec, UAT_RESTORE_OB_FROM_LIGHT_DUMP);
      CDRect rect;
      rect = pVec->GetRect();

      switch(m_iWidthUnits)
      {
      case UNITS_CM:
         rect.right = rect.left + m_dWidth * (VEC_UNITS_PER_INCH / CM_IN_INCH);
         break;
      case UNITS_INCH:
         rect.right = rect.left + m_dWidth * VEC_UNITS_PER_INCH ;
         break;
      case UNITS_PERCENT:
         rect.right = rect.left + (rect.right-rect.left) * (m_dWidth / 100);
         break;
      }

      switch(m_iHeightUnits)
      {
      case UNITS_CM:
         rect.bottom = rect.top + m_dHeight * (VEC_UNITS_PER_INCH / CM_IN_INCH);
         break;
      case UNITS_INCH:
         rect.bottom = rect.top + m_dHeight * VEC_UNITS_PER_INCH;
         break;
      case UNITS_PERCENT:
         rect.bottom = rect.top +  (rect.bottom-rect.top) * (m_dHeight / 100);
         break;
      }

      pVec->SetRect(rect);
   }
   m_pVecTstView->m_VecContainer.Repaint();
   m_pVecTstView->m_VecController.SetModified();

   m_dLastHeight = m_dHeight;
	m_dLastWidth = m_dWidth;
	m_iLastHeightUnits = m_iHeightUnits;
	m_iLastWidthUnits = m_iWidthUnits;
}
Ejemplo n.º 7
0
LONG CuDlgReplicationServerPageAssignment::OnUpdateData (WPARAM wParam, LPARAM lParam)
{
	LPIPMUPDATEPARAMS pUps = (LPIPMUPDATEPARAMS)lParam;
	CPtrList listInfoStruct;
	switch (pUps->nIpmHint)
	{
	case 0:
		break;
	default:
		return 0L;
	}
	
	ASSERT (pUps);
	try
	{
		REPLICSERVERDATAMIN RepSvrdta  = *((LPREPLICSERVERDATAMIN)pUps->pStruct);
		//
		// Empty the control:
		m_cListCtrl.DeleteAllItems();
		CdIpmDoc* pIpmDoc = (CdIpmDoc*)wParam;

		CaIpmQueryInfo queryInfo(pIpmDoc, OT_MON_REPLIC_CDDS_ASSIGN,pUps);
		queryInfo.SetNode((LPCTSTR)RepSvrdta.LocalDBNode);
		queryInfo.SetDatabase ((LPCTSTR)RepSvrdta.LocalDBName);

		BOOL bOK = IPM_QueryInfo (&queryInfo, listInfoStruct);
		if (bOK)
		{
			POSITION pos = listInfoStruct.GetHeadPosition();
			while (pos != NULL)
			{
				REPLICCDDSASSIGNDATAMIN* pCdds = (REPLICCDDSASSIGNDATAMIN*)listInfoStruct.GetNext(pos);
				AddItem (pCdds);
			}
		}
	}
	catch (CMemoryException* e)
	{
		theApp.OutOfMemoryMessage();
		e->Delete();
	}
	catch (CeIpmException e)
	{
		AfxMessageBox (e.GetReason(), MB_ICONEXCLAMATION|MB_OK);
	}

	while (!listInfoStruct.IsEmpty())
		delete (REPLICCDDSASSIGNDATAMIN*)listInfoStruct.RemoveHead();
	return 0L;
}
Ejemplo n.º 8
0
void Group::Add(CPtrList& listObj)
{
	Figure* pObj;
	POSITION pos = listObj.GetHeadPosition();
	while (pos)
	{
		pObj = (Figure*)listObj.GetNext(pos);
		pObj->SetGrouped(TRUE); //현재 개체가 그룹이 되었음을 표시
		if (pObj->thisobject() == MYGROUP) //그룹일 경우
			Child.AddTail((Group*)pObj); //차일드에 추가
		else //그룹이 아닐 경우
			NodeData.AddTail(pObj); //노드 데이터에 추가
	}
}
void CXTPMarkupEventHandlerMap::Raise(CXTPMarkupObject* pSender, CXTPMarkupRoutedEventArgs* pEventArgs)
{
	CPtrList* pHandlers;
	if (!m_mapHandlers.Lookup(pEventArgs->GetEvent(), pHandlers))
		return;

	POSITION pos = pHandlers->GetHeadPosition();

	while (pos)
	{
		CXTPMarkupDelegate* pDelegate = (CXTPMarkupDelegate*)pHandlers->GetNext(pos);

		pDelegate->Execute(pSender, pEventArgs);
	}
}
Ejemplo n.º 10
0
void CWindowManager::Close()
{
	CSingleLock pLock( &theApp.m_pSection, TRUE );
	CPtrList pClose;
	
	for ( POSITION pos = GetIterator() ; pos ; )
	{
		pClose.AddTail( GetNext( pos ) );
	}
	
	for ( pos = pClose.GetHeadPosition() ; pos ; )
	{
		CChildWnd* pChild = (CChildWnd*)pClose.GetNext( pos );
		pChild->DestroyWindow();
	}
}
Ejemplo n.º 11
0
void ChatDialog::OnExit(TNotifyUI& msg)
{
	thelockChatDlgList.Lock();
	POSITION pos,temp;
	for (pos=theChatDialogList.GetHeadPosition();pos!=NULL;)
	{
		temp = pos;
		ChatDialog* pDlg = (ChatDialog*)theChatDialogList.GetNext(pos);
		if (pDlg&&pDlg==this)
		{
			theChatDialogList.RemoveAt(temp);
		}
	}
	thelockChatDlgList.UnLock();
	Close();
}
Ejemplo n.º 12
0
BOOL CUpdateUtil::MakeClientXMLfile(CItemList *pItemListSoruce, LPCSTR lpszDestFilePath)
{
	if(!pItemListSoruce)
		return FALSE;

	CStdioFile writeFile;
	CString strFilePath = lpszDestFilePath;
	
	BOOL bFind = CheckFolder(strFilePath);
	if(bFind){
		if(!writeFile.Open(lpszDestFilePath, (CFile::modeCreate | CFile::modeWrite | CFile::typeText))){	
			SetLastError(UPDATE_ERROR_CANT_OPEN_XML_FILE);
			TRACE("UPDATE_ERROR_CANT_OPEN_XML_FILE : %s\n", lpszDestFilePath);
			return FALSE;
		}
	}
	else{
		return FALSE;
	}

	UTIL_CANCEL();
	CString strWriteLine, strFileName, strVersion, strDownPath, strCheckSum;
	strWriteLine = "<?xml version=\"1.0\" encoding=\"euc-kr\"?> \n";
	strWriteLine +=	"<update-data> \n\n";

	CPtrList* pPLServer = pItemListSoruce->GetPtrList();
	POSITION posServer = pPLServer->GetHeadPosition();
	while(posServer)
	{	
		UPDATE_DATA *psiServer = (UPDATE_DATA *)pPLServer->GetNext(posServer);
		strFileName = psiServer->Name;
		strVersion = psiServer->Version;
		strDownPath = psiServer->DownPath;
		strCheckSum = psiServer->CheckSum;
		strWriteLine +=	"\t<file name=\"" + strFileName + "\"> \n";
		strWriteLine += "\t\t<version>" + strVersion + "</version> \n";
		strWriteLine += "\t\t<downpath>" + strDownPath + "</downpath> \n";
		strWriteLine += "\t\t<checksum>" + strCheckSum + "</checksum> \n";
		strWriteLine += "\t</file> \n\n";
	}
	
	strWriteLine +=	"</update-data>";	
	writeFile.WriteString(strWriteLine);
	writeFile.Close();
//	TRACE("Write Xml File Success \n Contents : \n%s\n", strWriteLine);
	return TRUE;
}
Ejemplo n.º 13
0
CLibraryFolder* CLibraryFolderCtrl::GetNextSelectedFolder(POSITION& pos) const
{
	CLibraryFolder* pFolder = NULL;

	do
	{
		if ( pos == NULL ) return NULL;

		HTREEITEM hItem = (HTREEITEM)pos;
		pos = (POSITION)GetNextSelectedItem( hItem );

		if ( hItem == m_hRoot ) continue;

		CPtrList pTree;

		while ( hItem != m_hRoot )
		{
			pTree.AddHead( (LPVOID)hItem );
			hItem = GetParentItem( hItem );
		}

		CLibraryFolder* pLastFolder = NULL;

		for ( POSITION posTree = pTree.GetHeadPosition() ; posTree ; pLastFolder = pFolder )
		{
			hItem = (HTREEITEM)pTree.GetNext( posTree );
			pFolder = (CLibraryFolder*)GetItemData( hItem );

			if ( pLastFolder )
			{
				if ( pLastFolder->CheckFolder( pFolder ) ) continue;
			}
			else
			{
				if ( LibraryFolders.CheckFolder( pFolder ) ) continue;
			}

			pFolder = NULL;
			break;
		}
	}
	while ( pFolder == NULL );

	return pFolder;
}
Ejemplo n.º 14
0
STDMETHODIMP
CDirect2DRM::Tick(DWORD nElapsedTime)
{
	CPtrList			listTicked;
	LPD2DRMIMAGEPRIVATE pd2di;
	
	// NOTE: This code is NOT critical sectioned. This is because only images which
	// have textures will be on the ticked list and textures are ONLY released (and 
	// therefore their images removed from the ticked list) via the ReleaseTextures() 
	// method. The ReleaseTextures() method MUST be called from the same thread as 
	// this method.
	// REVIEW: The CS now added ALMOST removes the need for textures to be released in the
	// rendering thread. However it is still possible for the texture to be accessed
	// inside the image Tick after it has been destroyed.

	// Work through list (safely inside CS) plucking off images and AddRef'ing them
	// (need to AddRef 'cause could get a TextureDestroyCallback while we're in the
	// image Tick). Cannot do image Tick inside CS since can deadlock with DelTicked
	// which will be called from TextureDestroyCallback (inside D3D CS).
	EnterCriticalSection(&m_CSTickedList);

	for (POSITION pos = m_listTicked.GetHeadPosition(); pos;)
	{
		pd2di = (LPD2DRMIMAGEPRIVATE) m_listTicked.GetNext(pos);

		if (pd2di)
			pd2di->AddRef();

		listTicked.AddTail(pd2di);
	}
	LeaveCriticalSection(&m_CSTickedList);

	// Now Tick the AddRef'd images from this separate list.
	for (pos = listTicked.GetHeadPosition(); pos;)
	{
		pd2di = (LPD2DRMIMAGEPRIVATE) listTicked.GetNext(pos);
		if (pd2di)
			pd2di->Tick(nElapsedTime);
		MMRELEASE(pd2di);
	}

	return S_OK;
}
Ejemplo n.º 15
0
//删除客户端
void CTCPServer_CE::RemoteClient(CTCPCustom_CE *pClient /*客户端对象*/)
{
	POSITION posPrior;
	POSITION pos = m_ListClientSocket.GetHeadPosition();

	while (pos != NULL)
	{
		posPrior = pos;
        CTCPCustom_CE *pTcpCustom = (CTCPCustom_CE*)m_ListClientSocket.GetNext(pos);
		if (pTcpCustom == pClient)
		{
			//释放内存
			delete pTcpCustom;
			pTcpCustom = NULL;
			m_ListClientSocket.RemoveAt(posPrior);
			TRACE(L"移出了一个客户端对象\n");
			break;
		}
	}
}
Ejemplo n.º 16
0
void KDicomDS::DeleteElement(KDicomElement * pDE, KDicomElement * pParent)
{
    CPtrList * pList;
    if(pParent == NULL)
        pList = & m_listDE;
    else
        pList = &(pParent->m_listDE);

    KDicomElement * pDET;
    POSITION p_pos;
    POSITION pos = pList->GetHeadPosition();
    while(pos != NULL) {
        p_pos = pos;
        pDET = (KDicomElement *) pList->GetNext(pos);
        if(pDET == pDE) {
            pList->RemoveAt(p_pos);
            delete pDE;
            return;
        }
    }
}
Ejemplo n.º 17
0
void CInfGame::SetGlobals(CPtrList &list)
{
	INF_GAME_GLOBAL *pGlobal;
	POSITION pos = m_plGlobals.GetHeadPosition();
	while(pos)
	{
		pGlobal = (INF_GAME_GLOBAL*)m_plGlobals.GetNext(pos);
		delete pGlobal;
	}
	m_plGlobals.RemoveAll();

	pos = list.GetHeadPosition();
	while(pos)
	{
		pGlobal = (INF_GAME_GLOBAL*)list.GetNext(pos);
		m_plGlobals.AddTail(pGlobal);
	}
	m_infGame.dwGlobalVarCount = m_plGlobals.GetCount();

	list.RemoveAll();
}
Ejemplo n.º 18
0
/*-----------------------------------------------------------------
【函数介绍】:  关闭TCP服务
【入口参数】:  (无)
【出口参数】:  (无)
【返回  值】:  <=0:关闭TCP服务失败; =1:关闭TCP服务成功
------------------------------------------------------------------*/
int CTCPServer_CE::Close()
{
	//结束通讯线程
	SetEvent(m_exitThreadEvent);
	//等待1秒,如果读线程没有退出,则强制退出
	if (WaitForSingleObject(m_serverThreadHandle,1000) == WAIT_TIMEOUT)
	{
		TerminateThread(m_serverThreadHandle,0);
		TRACE(L"强制终止服务器端线程\n");
	}
	m_serverThreadHandle = NULL;
	//关闭Socket,释放资源
	int err = closesocket(m_ServerSocket);
	if (err == SOCKET_ERROR)
	{
		return -1;
	}

	//首先,关闭与所有客户端连接
	POSITION pos = m_ListClientSocket.GetHeadPosition();
	while (pos != NULL)
	{
		//得到客户端对象
        CTCPCustom_CE *pTcpCustom = (CTCPCustom_CE*)m_ListClientSocket.GetNext(pos);
		if (!pTcpCustom->Close())
		{
			TRACE(L"关闭客户端socket错误");
		}

		//释放内存
		delete pTcpCustom;
		pTcpCustom = NULL;
	}

	m_ListClientSocket.RemoveAll();
	
	WSACleanup();
	return 1;
}   
Ejemplo n.º 19
0
void CPicTransparentDlg::Apply()
{
   CPtrList SelItems;
   m_pVecTstView->GetSelectedItems(SelItems);
   POSITION pos = SelItems.GetHeadPosition();
   m_pVecTstView->m_VecController.m_UndoManager.CreateNewStep();
   while(pos!=NULL)
   {
      CVecBase* pVec = (CVecBase*)SelItems.GetNext(pos);
      CVecBitmapBase* pBitmapBase = dynamic_cast<CVecBitmapBase*>(pVec);
      if(pBitmapBase!=NULL)
      {
         m_pVecTstView->m_VecController.m_UndoManager.AddActionToLastStep(pVec, UAT_RESTORE_OB_FROM_LIGHT_DUMP);
         pBitmapBase->SetTransparent(m_bIsTransparent);

		pVec->SetShadowColor(m_clrTransparent);


      }
   }
   m_pVecTstView->m_VecContainer.Repaint();
   m_pVecTstView->m_VecController.SetModified();
}
Ejemplo n.º 20
0
/*-----------------------------------------------------------------
【函数介绍】:  发送数据
【入口参数】:  pCustomCE :客户端对象指针
			   buf : 缓冲区
			   dwBufLen : 缓冲区长度
【出口参数】:  (无)
【返回  值】:  TRUE : 发送成功 ; FALSE : 发送失败
------------------------------------------------------------------*/
BOOL CTCPServer_CE::SendData(CTCPCustom_CE* pCustomCE, const char * buf , DWORD dwBufLen)
{
	BOOL bResult = FALSE;
	BOOL bExisted = FALSE;
	if (pCustomCE == NULL)
	{
		return FALSE;
	}

	//判断此客户端是否存在
	POSITION pos = m_ListClientSocket.GetHeadPosition();
	while (pos != NULL)
	{
        CTCPCustom_CE *pTcpCustom = (CTCPCustom_CE*)m_ListClientSocket.GetNext(pos);

		if (pCustomCE == pTcpCustom)
		{
			bExisted = TRUE;
			break;
		}
	}
	if (!bExisted)
	{
		return FALSE;
	}

	bResult =  pCustomCE->SendData(buf,dwBufLen);

	if (!bResult)
	{
		//
		RemoteClient(pCustomCE);
	}

	return bResult;
}
Ejemplo n.º 21
0
void COwnedLostItem::FetchPrettyName()
{
	if (IsInternetShortcut())
		m_csPrettyName = MakeInternetShortcutName();

	CPtrList* allHelpers = &(CHelperApp::m_cplHelpers);

	for (POSITION pos = allHelpers->GetHeadPosition(); pos != NULL;)
	{
		CHelperApp* app = (CHelperApp*)allHelpers->GetNext(pos);
		CString helperMime(app->cd_item->ci.type);

		if (helperMime == m_csMimeType)
		{
			CString returnString = app->cd_item->ci.desc;
			if (returnString == "")
				returnString = "File Type";

			if (app->cd_item->num_exts > 0)
			{
				returnString += " (";
				for (int i = 0; i < app->cd_item->num_exts; i++)	
				{
					returnString += "*.";
					returnString += app->cd_item->exts[i];

					if (i < app->cd_item->num_exts-1)
					  returnString += "; ";
				}
				returnString += ")";
			}

			m_csPrettyName = returnString;
		}
	}
}
Ejemplo n.º 22
0
void CInfCreature::SetAffects(CPtrList &list)
{
	INF_AFF *pAff;
	POSITION posPrev;
	POSITION pos = m_plAffects.GetHeadPosition();
	while(pos)
	{
		posPrev = pos;
		pAff = (INF_AFF*)m_plAffects.GetNext(pos);

		// Delete all the affects except those handled elsewhere.
		if (pAff->dwAffectType == AFF_TYPE_PROF ||	
			 (pAff->dwAffectType == AFF_TYPE_SPELL && !strnicmp(pAff->chResRef3,"SPCL812",7))
			)
			continue;

		delete pAff;
		m_plAffects.RemoveAt(posPrev);
		m_infCre.dwAffectCount--;
		if (m_infCre.dwAffectCount < 0)
			m_infCre.dwAffectCount = 0;

		pos = m_plAffects.GetHeadPosition();
	}

	pos = list.GetHeadPosition();
	while(pos)
	{
		pAff = (INF_AFF*)list.GetNext(pos);

		m_plAffects.AddTail(pAff);
		m_infCre.dwAffectCount++;
	}

	list.RemoveAll();
}
Ejemplo n.º 23
0
/////////////////////////////////////////////////////////
// Demonstrate:
// IADsPropertyList::GetPropertyItem
// IADsPropertyEntry
//
void CDlgIADsPropertyList::OnGet()
{

    HRESULT hr;
    CString s;
    BSTR    bstr;
    VARIANT var;
    IDispatch *pDispatch;
    IADsPropertyEntry *pEntry;
    IADsPropertyValue *pValue;
    LONG  lADsType;


    UpdateData(TRUE);
    m_cValueList.ResetContent();

    bstr = m_sAttribute.AllocSysString();
    hr = m_pPropList->GetPropertyItem( bstr, m_cADsType.GetCurSel()+1, &var );
    SysFreeString( bstr );


    if ( SUCCEEDED(hr) )
    {
        pDispatch = V_DISPATCH( &var );
        hr = pDispatch->QueryInterface( IID_IADsPropertyEntry, (void**) &pEntry );
        VariantClear( &var );

        // IADsPropertyEntry
        if ( SUCCEEDED(hr) )
        {
            CPtrList dList;

            // get_Values return array of VT_DISPATH
            hr = pEntry->get_Values( &var );


            pEntry->get_ADsType( &lADsType);

            hr = VariantToPtrList( var, dList );

            pEntry->Release();

            ////////////////////////////
            // IADsPropertyValue
            /////////////////////////////
            if ( SUCCEEDED(hr) )
            {
                POSITION pos;
                pos = dList.GetHeadPosition();
                while ( pos != NULL )
                {
                    pDispatch = (IDispatch*) dList.GetAt(pos);
                    hr = pDispatch->QueryInterface( IID_IADsPropertyValue, (void**) &pValue );

                    if ( SUCCEEDED(hr) )
                    {
                        pValue->AddRef();
                        hr = PropertyValueToString( lADsType, pValue, s );
                        m_cValueList.AddString( s );
                        pValue->Release();
                    }
                    dList.GetNext(pos);
                }

            }

            dList.RemoveAll();
            VariantClear(&var);

        }

    }
}
Ejemplo n.º 24
0
void
CDisplayVars::CopyDisplayVars( DisplayVars *pDV, CDisplayVars *nDisplayVars, CDocument *pDC )
{

	pDV->m_GroupEnabled = nDisplayVars->GetGroupEnabled();

	pDV->m_PrimaryLevel = nDisplayVars->GetPrimaryLevel();
	pDV->m_SecondaryLevel = nDisplayVars->GetSecondaryLevel();
	pDV->m_TertiaryLevel = nDisplayVars->GetTertiaryLevel();
	
	pDV->m_ModeConserved = nDisplayVars->GetModeConserved();

	// Where do we make the call for this?
	pDV->m_LastShadeLevel = nDisplayVars->GetLastShadeLevel();

	pDV->m_ResidueMode = nDisplayVars->GetResidueMode();

	// Copy Those to these ...
	pDV->m_DiffMode = nDisplayVars->GetDiffMode();

	pDV->m_PropStyle = nDisplayVars->GetPropStyle();

	nDisplayVars->GetTitleColors ( &pDV->m_TitleTextColor, &pDV->m_TitleBkColor);

	pDV->m_ConsSubStyle = nDisplayVars->GetConsSubStyle();

	// Copy property ...
	pDV->m_Property.CopyVars( nDisplayVars->GetProperty() );

	pDV->m_StcGroup.CopyVars( nDisplayVars->GetStcGroup() );

	//
	pDV->m_GroupName = nDisplayVars->GetGroupName();

	// Clear current contents of list.
	pDV->m_GroupList.RemoveAll();

	CPtrList *listGN = nDisplayVars->GetGroupList();

	CGenedocDoc *pDoc = (CGenedocDoc *)pDC;

	POSITION tPos = listGN->GetHeadPosition();

	while ( tPos != NULL ) {
		CGeneSegment * pCGSeg = (CGeneSegment *)listGN->GetNext(tPos);

		POSITION sPos = pDoc->pGSFiller->SegDataList.GetHeadPosition();
		while (sPos != NULL ) {

			CGeneSegment *tCGSeg = (CGeneSegment *)pDoc->pGSFiller->SegDataList.GetNext(sPos);

			if ( tCGSeg->GetStyle() != LINESEQUENCE ) continue;

			if ( tCGSeg->GetTitle() == pCGSeg->GetTitle() ) {
				pDV->m_GroupList.AddTail ( tCGSeg );
				break;
			}

		}
	}


	// Clear current contents of list.
	pDV->m_IdentList.RemoveAll();

	listGN = nDisplayVars->GetIdentList();

	tPos = listGN->GetHeadPosition();

	while ( tPos != NULL ) {
		CGeneSegment * pCGSeg = (CGeneSegment *)listGN->GetNext(tPos);

		POSITION sPos = pDoc->pGSFiller->SegDataList.GetHeadPosition();
		while (sPos != NULL ) {

			CGeneSegment *tCGSeg = (CGeneSegment *)pDoc->pGSFiller->SegDataList.GetNext(sPos);

			if ( tCGSeg->GetStyle() != LINESEQUENCE ) continue;

			if ( tCGSeg->GetTitle() == pCGSeg->GetTitle() ) {
				pDV->m_IdentList.AddTail ( tCGSeg );
				break;
			}

		}
	}
	nDisplayVars->GetIdentColors ( &pDV->m_IdentTextColor, &pDV->m_IdentBkColor);
	pDV->m_IdentDisplayStyle = nDisplayVars->GetIdentDisplayStyle();


}
Ejemplo n.º 25
0
void COwnedAndLostList::ConstructLists()
{
	CString pathString;
	pathString.LoadString(IDS_NETHELP_REGISTRY); // Software\Netscape\Netscape Navigator

	// Read in the owned list
	// Look for owned subkey
	// If subkey exists, iterate over its subkeys and build the owned list
	// If subkey does not exist, the owned list should contain a certain
	// list of built-in types.  These are the types that Netscape defends initially.
	HKEY ownedKey, lostKey;
	CString ownerPath = pathString + "Owned";
	LONG result = ::RegOpenKey(HKEY_CURRENT_USER, ownerPath, &ownedKey);
	
	// Prepopulate our list with some types we want to defend.

	int dwIndex;
	char nameBuffer[_MAX_PATH];
	unsigned long nameBufferSize, valueBufferSize;
	unsigned char valueBuffer[_MAX_PATH];
	unsigned long typeCodeBuffer = 0;

	if (result != ERROR_SUCCESS)
	{
		m_OwnedList.Add(new COwnedLostItem("text/html"));
		m_OwnedList.Add(new COwnedLostItem("image/jpeg"));
		m_OwnedList.Add(new COwnedLostItem("image/pjpeg"));
		m_OwnedList.Add(new COwnedLostItem("image/gif"));
		m_OwnedList.Add(new COwnedLostItem("application/x-javascript"));
		m_OwnedList.Add(new COwnedLostItem("image/x-xbitmap"));
		
		// Be prepared to defend Internet Shortcuts if they are ever installed
		// later! 
		m_OwnedList.Add(new COwnedLostItem("application/x-http-protocol"));
		m_OwnedList.Add(new COwnedLostItem("application/x-https-protocol"));
		m_OwnedList.Add(new COwnedLostItem("application/x-news-protocol"));
		m_OwnedList.Add(new COwnedLostItem("application/x-snews-protocol"));
		m_OwnedList.Add(new COwnedLostItem("application/x-ftp-protocol"));
		m_OwnedList.Add(new COwnedLostItem("application/x-gopher-protocol"));
	}
	else
	{
		// Read in the owned list
		dwIndex = 0;
		valueBufferSize = sizeof(valueBuffer);
		nameBufferSize = sizeof(nameBuffer);
		while (RegEnumValue(ownedKey, dwIndex, nameBuffer, 
				&nameBufferSize, NULL, &typeCodeBuffer, valueBuffer,
				&valueBufferSize) != ERROR_NO_MORE_ITEMS)
		{
			m_OwnedList.Add(new COwnedLostItem(nameBuffer, valueBuffer));
			dwIndex++;
			valueBufferSize = sizeof(valueBuffer);
			nameBufferSize = sizeof(nameBuffer);
		}

	}

	// Read in the lost list
	// Look for lost subkey
	// If subkey exists, iterate over its subkeys and build the lost list
	// If subkey does not exist, the lost list is initially empty.  Do nothing.
	CString lostPath = pathString + "Lost";
	result = ::RegOpenKey(HKEY_CURRENT_USER, lostPath, &lostKey);
	
	if (result == ERROR_SUCCESS)
	{
		// Read in the lost list
		dwIndex = 0;
		valueBufferSize = sizeof(valueBuffer);
		nameBufferSize = sizeof(nameBuffer);
		while (RegEnumValue(lostKey, dwIndex, nameBuffer, 
				&nameBufferSize, NULL, &typeCodeBuffer, valueBuffer,
				&valueBufferSize) != ERROR_NO_MORE_ITEMS)
		{
			m_LostList.Add(new COwnedLostItem(nameBuffer, valueBuffer));
			dwIndex++;
			valueBufferSize = sizeof(valueBuffer);
			nameBufferSize = sizeof(nameBuffer);
		}
	}

	// Iterate over the owned list. Look up each entry in the helper app list.  If
	// it is not handled by the current Netscape, then move it to the lost list.
	int count = m_OwnedList.GetSize();
	for (int i = 0; i < count; i++)
	{
		COwnedLostItem* theItem = (COwnedLostItem*)(m_OwnedList[i]);
		
		if (theItem->m_nHandleMethod != OL_CURRENT_NETSCAPE)
		{
			// Move to the lost list
			void* thePtr = m_OwnedList[i];
			m_OwnedList.RemoveAt(i);
			m_LostList.Add(thePtr);
			i--;
			count--;
		}
	}

	// Iterate over the lost list.  If any entry is now handled by the current Netscape, move it to
	// the owner list
	count = m_LostList.GetSize();
	for (i = 0; i < count; i++)
	{
		COwnedLostItem* theItem = (COwnedLostItem*)(m_LostList[i]);
		
		if (theItem->m_nHandleMethod == OL_CURRENT_NETSCAPE)
		{
			// Move to the owned list
			m_LostList.RemoveAt(i);
			m_OwnedList.Add(theItem);
			i--;
			count--;
		}
	}

	// Iterate over all the helper apps and find any additional entries that aren't in the
	// owned list or lost list (and that should be).
	
	CPtrList* allHelpers = &(CHelperApp::m_cplHelpers);
	for (POSITION pos = allHelpers->GetHeadPosition(); pos != NULL;)
	{
		CHelperApp* app = (CHelperApp*)allHelpers->GetNext(pos);
		CString helperMime(app->cd_item->ci.type);

		COwnedLostItem theItem(helperMime);
		if (theItem.m_nHandleMethod == OL_CURRENT_NETSCAPE &&
			!IsInOwnedList(helperMime))
		{
			// This should be in the owned list, since we apparently control it.
			COwnedLostItem* realItem = new COwnedLostItem(helperMime);
			m_OwnedList.Add(realItem);
		}
		else if (theItem.m_nHandleMethod == OL_OLD_NETSCAPE &&
			!IsInLostList(helperMime))
		{
			// This item is currently used by the old Netscape.  Let's
			// offer to update to the current version of NS.
			COwnedLostItem* realItem = new COwnedLostItem(helperMime);
			m_LostList.Add(realItem);
		}
	}

	// Netscape will automatically wrest control of HTML files from a previous version
	// so we don't REALLY want HTML in our lost list if it is controlled by an older version
	// of netscape.  It should be moved to our OWNED list instead, and the handle method
	// should be updated.
	if (IsInLostList("text/html"))
	{
		COwnedLostItem* theItem = RemoveFromLostList("text/html");
		if (theItem)
		{
			if (theItem->m_nHandleMethod == OL_OLD_NETSCAPE)
			{
				theItem->m_nHandleMethod = OL_CURRENT_NETSCAPE;
				m_OwnedList.Add(theItem);  // Move it to the owned list
			}
			else m_LostList.Add(theItem); // Put it back
		}
	}

	if (IsInLostList("application/x-unknown-content-type-NetscapeMarkup"))
	{
		COwnedLostItem* theItem = RemoveFromLostList("application/x-unknown-content-type-NetscapeMarkup");
		if (theItem)
		{
			if (theItem->m_nHandleMethod == OL_OLD_NETSCAPE)
			{
				theItem->m_nHandleMethod = OL_CURRENT_NETSCAPE;
				m_OwnedList.Add(theItem);  // Move it to the owned list
			}
			else m_LostList.Add(theItem); // Put it back
		}
	}
}
Ejemplo n.º 26
0
void CedExporter::CreateExport(CeMap* cedFile)
{
	//CleanObjectLists(cedFile);
	//return;

	// Ensure root folders exist (methods will quietly fail if folders are already there)
	CreateDirectory("C:\\Backsight", 0);
	CreateDirectory("C:\\Backsight\\index", 0);

	// Ensure the export has not been done already by looking for an existing index entry
	LPCTSTR mapName = cedFile->GetFileName();
	CString indexFileName;
	indexFileName.Format("C:\\Backsight\\index\\%s.txt", mapName);
	CFileStatus fileStatus;
	if (CFile::GetStatus((LPCTSTR)indexFileName, fileStatus))
	{
		AfxMessageBox("Map has been exported previously");
		return;
	}

	IdFactory idFactory;
	CPtrArray items;

	// Generate a GUID for the project
	CString guid;
	FillGuidString(guid);

	// Record the current computer name
	CString machineName;
	FillComputerName(machineName);

	// Create the new project event (assuming UTM zone 14 on NAD83)
	CTime now = CTime::GetCurrentTime();
	int layerId = 10; // Survey layer
	items.Add(new NewProjectEvent_c(idFactory, now, (LPCTSTR)guid, mapName, layerId, "UTM83-14", "CEdit", (LPCTSTR)machineName));

	// Invent a pseudo-session to enclose all ID allocations (and any other stuff)
	items.Add(new NewSessionEvent_c(idFactory, now, "CEdit", ""));

	CeIdManager* idMan = CeIdHandle::GetIdManager();
	unsigned int nGroup = idMan->GetNumGroup();

	for (unsigned int i=0; i<nGroup; i++)
	{
		const CeIdGroup* group = idMan->GetpGroup(i);
		int groupId = idFactory.GetGroupId(group->GetGroupName());
		const CPtrList& ranges = group->GetIdRanges();

		POSITION pos = ranges.GetHeadPosition();
		while ( pos )
		{
			CeIdRange* range = (CeIdRange*)ranges.GetNext(pos);
			items.Add(new IdAllocation_c(idFactory, now, groupId, range->GetMin(), range->GetMax()));
		}
	}

	// Produce a definitive (correct) list of the features created
	// be each edit. This aims to overcome a defect in the lists associated
	// with CeImport edits (and perhaps other edits).
	idFactory.GenerateOperationFeatureLists(cedFile);
	
	// Generate any points that will be needed for line ends (whereas CEdit would let you have lines without
	// an end point, Backsight requires them)
	ImportOperation_c* extra = new ImportOperation_c(idFactory, now);
	GenerateExtraPoints(cedFile, idFactory, extra->Features);
	//AfxMessageBox("done extra points");

	// Represent the points as an import operation
	if (extra->Features.GetSize() == 0)
		delete extra;
	else
		items.Add(extra);

	items.Add(new EndSessionEvent_c(idFactory, now));

	// Now loop through each session (but ignore empty sessions).
	CPSEPtrList& sessions = cedFile->GetSessions();
	POSITION spos = sessions.GetHeadPosition();
	int totop = 0;

	while (spos != 0)
	{
		CeSession* session = (CeSession*)sessions.GetNext(spos);
		const CPSEPtrList& ops = session->GetOperations();
		int nop = ops.GetCount();
		totop += nop;

		if (nop > 0)
		{
			// Append the NewSessionEvent
			CTime startTime(session->GetStart().GetTimeValue());
			CTime endTime(session->GetEnd().GetTimeValue());
			items.Add(new NewSessionEvent_c(idFactory, startTime, (LPCTSTR)session->GetpWho()->GetpWho(), ""));

			// Figure out the average time between successive edits (treat the end session event as an "edit")
			LONG sessionSecs = (endTime - startTime).GetTotalSeconds();
			LONG secsPerEdit = sessionSecs / (nop + 2);

			POSITION opos = ops.GetHeadPosition();
			for (int i=0; i<nop; i++)
			{
				CeOperation* op = (CeOperation*)ops.GetNext(opos);
				LONG secs = (i+1) * secsPerEdit;
				CTimeSpan delta(0,0,0, secs);
				CTime when = startTime + delta;
				AppendExportItems(when, *op, idFactory, items);
			}

			// Append the end session event
			items.Add(new EndSessionEvent_c(idFactory, endTime));
		}
	}

	// Clear the lists of features associated with each edit
	idFactory.ClearOperationFeatureLists();

	// test
	CString t;
	t.Format("Number of edits=%d", totop);
	AfxMessageBox(t);
	//return;

	// Create the project folder
	CString projectFolder;
	projectFolder.Format("C:\\Backsight\\%s", (LPCTSTR)guid);
	CreateDirectory((LPCTSTR)projectFolder, 0);

	// Produce the output file
	unsigned int maxId = idFactory.GetNextId();
	CString fileName;
	fileName.Format("%s\\%u.txt", (LPCTSTR)projectFolder, maxId);

	FILE* fp = fopen((LPCTSTR)fileName, "w");
	TextEditWriter* tw = new TextEditWriter(fp);
	EditSerializer* es = new EditSerializer(idFactory, *tw);

	for (int ix=0; ix<items.GetSize(); ix++)
	{
		Persistent_c* p = (Persistent_c*)items.GetAt(ix);
		es->WritePersistent(DataField_Edit, *p);
	}

	delete es;
	delete tw;
	fclose(fp);

	// Write the index entry file
	fp = fopen((LPCTSTR)indexFileName, "w");
	fprintf(fp, "%s", (LPCTSTR)guid);
	fclose(fp);
	
	// Write point positions file
	CString ptsFileName;
	ptsFileName.Format("%s\\%s.pts", (LPCTSTR)projectFolder, mapName);
	idFactory.WritePointsFile((LPCTSTR)ptsFileName);

	// Remove the export objects
	for (int ip=0; ip<items.GetSize(); ip++)
	{
		Persistent_c* p = (Persistent_c*)items.GetAt(ip);
		delete p;
	}

	// Dump out attributes...

	// Obtain the mapping from schema to output file extension (for consistency with
	// current data distributions done by GeoManitoba).
	CeExportTypeUtil xt;
	int rcode = xt.Load();
	if ( rcode < 0 )
	{
		CString msg;
		xt.GetLoadMessage(msg,rcode);
		AfxMessageBox(msg);
		return;
	}

	// Collect the IDs
	CPtrList ids;
	cedFile->GetIds(ids);

	// Collect the rows attached to the IDs
	CPtrList rows;
	CeTableEx::CollectRows(rows, ids);

	// Group by table. Then dispense with the list of pointers to rows.
	CPtrList tables;
	CeTableEx::BinRows(tables, rows);
	rows.RemoveAll();

	// Go through each bin, exporting the info to an output text file.	
	POSITION pos = tables.GetHeadPosition();
	CString tableFileName;

	while ( pos )
	{
		CeTableEx* pTable = (CeTableEx*)tables.GetNext(pos);

		// Determine the name of the output file (based on the name of the schema)
		const CeSchema& schema = pTable->GetSchema();
		tableFileName.Format("%s\\%s-%s.txt", (LPCTSTR)projectFolder, mapName, xt.GetFileType(schema));

		// Write out the attributes
		pTable->Export((LPCTSTR)tableFileName);
		delete pTable;
	}

	// Remove pointers to the tables (now deleted).
	tables.RemoveAll();
}
Ejemplo n.º 27
0
BOOL CUpdateUtil::Download(PUPDATE_TRANSNOTIFY pNotiInfo, CItemList *pItemListSoruce, CItemList *pItemListDest)
{
	CPtrList* pPLClient = pItemListDest->GetPtrList();
	CPtrList* pPLServer = pItemListSoruce->GetPtrList();
	
	UTIL_CANCEL();
	// Server Update check 
	POSITION posServer = pPLServer->GetHeadPosition();
	while(posServer)
	{	
		UPDATE_DATA *psiServer = (UPDATE_DATA *)pPLServer->GetNext(posServer);
		
		if(psiServer->UpdateFlag == UPDATE_FLAG_UPDATE || psiServer->UpdateFlag == UPDATE_FLAG_NEW){
			CString strSrcURL = psiServer->DownURL;
			UTIL_CANCEL();
			pNotiInfo->nCurrentSize = 0;
			if(DownloadFileCheck(pNotiInfo, strSrcURL)){
				pNotiInfo->nErrno = UPDATE_ERROR_NONE;
				pNotiInfo->nTotalSize += pNotiInfo->nCurrentSize;
				pNotiInfo->nTotalCount++;
				psiServer->Size = pNotiInfo->nCurrentSize;
			}
		}
	}
	
	UTIL_CANCEL();
	posServer = pPLServer->GetHeadPosition();
	while(posServer)
	{	
		BOOL bExist = FALSE;
		UPDATE_DATA *psiServer = (UPDATE_DATA *)pPLServer->GetNext(posServer);
		
		if(psiServer->UpdateFlag == UPDATE_FLAG_UPDATE || psiServer->UpdateFlag == UPDATE_FLAG_NEW){
			CString strSrcURL = psiServer->DownURL;
			CString strDownFolderPath  = psiServer->DownPath;
			UTIL_CANCEL();
			pNotiInfo->lpszName = psiServer->Name;
			pNotiInfo->lpszVersion = psiServer->Version;
			pNotiInfo->lpszDownURL = psiServer->DownURL;
			pNotiInfo->lpszDownPath = psiServer->DownPath;
			pNotiInfo->lpszDescription = psiServer->Description;
			pNotiInfo->nCurrentSize = psiServer->Size;
			pNotiInfo->nCurrentCount++;
			pNotiInfo->nErrno = UPDATE_ERROR_NONE;
			pNotiInfo->nSendPos = 0;
			SendFileNotify(pNotiInfo);
			switch(psiServer->OptionFlag)
			{
			case UPDATE_OPTION_FLAG_RENAME:
				pNotiInfo->pInfo->bNewCreateFile = TRUE;
				break;
			default:
				break;
			}
			
			if(DownloadFile(pNotiInfo, strSrcURL, strDownFolderPath, psiServer->CheckSum)){
				TRACE("Download Complete : %s of %s\n", strSrcURL, psiServer->Name);
				if(strcmp(psiServer->RegSrv, UPDATE_REGSVR) == 0){
					CString strDownFilePath;
					CString strTmp = psiServer->Name;
					strDownFilePath = strDownFolderPath + "\\" + strTmp;
					if(RegSvr32(strDownFilePath))
						TRACE("RegSvr32 Successs : %s\n", psiServer->Name);
					else
						TRACE("RegSvr32 Failed : %s\n", psiServer->Name);
				}
			}
			else{
				TRACE("Download Failed : %s of %s\n", strSrcURL, psiServer->Name);
				return FALSE;
			}
		}
	}
	
	// Client delete check
	POSITION posClient = pPLClient->GetHeadPosition();
	while(posClient)
	{	
		BOOL bExist = FALSE;
		UPDATE_DATA *psiClient = (UPDATE_DATA *)pPLClient->GetNext(posClient);

		if(psiClient->UpdateFlag == UPDATE_FLAG_DELETE){
			UTIL_CANCEL();
			CString strFilePath;
			strFilePath.Format("%s\\%s", psiClient->DownPath, psiClient->Name);
			if(DeleteFile(strFilePath))
				TRACE("Delete Failed : %s\n", strFilePath);
			else
				TRACE("Delete Failed : %s\n", strFilePath);
		}
	}

	return MakeClientXMLfile(pItemListSoruce, pNotiInfo->pInfo->lpszDestXmlFile);
}
Ejemplo n.º 28
0
void COwnedLostItem::GiveControlToNetscape()
{	
	char buffer[_MAX_PATH];
	::GetModuleFileName(theApp.m_hInstance, buffer, _MAX_PATH);
	
	// Get the app's directory into a short file name
	char shortBuffer[_MAX_PATH];
	GetShortPathName(buffer, shortBuffer, _MAX_PATH);

	CString directoryName(shortBuffer);
	directoryName.MakeUpper();  // This is what we'll write to the registry

	CString strValueName, strCmdPath;

	// Special Internet Shortcut check
	if (IsInternetShortcut())
	{
		CInternetShortcut internetShortcut;
		if (internetShortcut.ShellSupport())
		{
			// Need to take over lots of stuff
			CString strType = GetInternetShortcutFileClass();
			
			// Set the open command path
			strValueName.Format(strOPEN_CMD_FMT, (const char *)strType);
			strCmdPath = directoryName + " -h \"%1\"";
			FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strCmdPath);
		
			// Set the DDE exec value
			strValueName.Format(strDDE_EXEC_FMT, (const char *)strType);
			FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strDDE_EXEC_VALUE);

			// Set the DDE app name
			strValueName.Format(strDDE_APP_FMT, (const char *)strType);
			FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strDDE_APP_NAME);
							
			// Set the DDE topic
			strValueName.Format(strDDE_TOPIC_FMT, (const char *)strType);
			CString strDDETopic;
			strDDETopic.LoadString(IDS_DDE_OPENURL);
			FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strDDETopic);

			// Set the Default Icon
			CString strIconPath;
			if ((strType == "news") || (strType == "snews"))
			{
				// Use the news icon from URL.DLL
				::GetSystemDirectory(buffer, _MAX_PATH);
				strIconPath = CString(buffer) + "\\URL.DLL,1";
			}  
			else
			{
				// Use the document icon
				strIconPath = CString(buffer) + ",1";
			}  
			strValueName.Format(strDEF_ICON_FMT, (const char *)strType);
			FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strIconPath);
			
			// Take over printing (applies to ALL Internet Shortcuts.  If we own one, we'll take
			// over printing for ALL of them).
			CString csMunge = directoryName + " /print(\"%1\")";
			FEU_RegistryWizard(HKEY_CLASSES_ROOT, "InternetShortcut\\shell\\print\\command", csMunge);
            FEU_RegistryWizard(HKEY_CLASSES_ROOT, "InternetShortcut\\shell\\print\\ddeexec", "[print(\"%1\")]");
            FEU_RegistryWizard(HKEY_CLASSES_ROOT, "InternetShortcut\\shell\\print\\ddeexec\\Application", strDDE_APP_NAME);

			//  The PrintTo Command.
            csMunge = directoryName + " /printto(\"%1\",\"%2\",\"%3\",\"%4\")";
            FEU_RegistryWizard(HKEY_CLASSES_ROOT, "InternetShortcut\\shell\\PrintTo\\command", csMunge);
            FEU_RegistryWizard(HKEY_CLASSES_ROOT, "InternetShortcut\\shell\\PrintTo\\ddeexec", "[printto(\"%1\",\"%2\",\"%3\",\"%4\")]");
            FEU_RegistryWizard(HKEY_CLASSES_ROOT, "InternetShortcut\\shell\\PrintTo\\ddeexec\\Application", strDDE_APP_NAME);
		}

		return;
	}

	CPtrList* allHelpers = &(CHelperApp::m_cplHelpers);

	for (POSITION pos = allHelpers->GetHeadPosition(); pos != NULL;)
	{
		CHelperApp* app = (CHelperApp*)allHelpers->GetNext(pos);
		CString helperMime(app->cd_item->ci.type);

		if (helperMime == m_csMimeType)
		{
			// Found the helper app.  Get the file class.
			CString fileClass(app->strFileClass);
			if (fileClass != "")
			{
				// We have some registry work to do.
				// In the case where this is text/html, we point .htm and .html to
				// NetscapeMarkup.
				HKEY hKey;
				DWORD dwDisp;

				if (m_csMimeType == "text/html")
				{
					::RegCreateKeyEx(HKEY_CLASSES_ROOT,
						".htm", 0L, NULL,
						REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
						&hKey, &dwDisp);
					::RegSetValueEx(hKey, NULL, 0L, REG_SZ,
						(const BYTE *)((const char *)strMARKUP_KEY),
						strMARKUP_KEY.GetLength() + 1);
					::RegCloseKey(hKey);
					
					::RegCreateKeyEx(HKEY_CLASSES_ROOT,
						".html", 0L, NULL,
						REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
						&hKey, &dwDisp);
					::RegSetValueEx(hKey, NULL, 0L, REG_SZ,
						(const BYTE *)((const char *)strMARKUP_KEY),
						strMARKUP_KEY.GetLength() + 1);
					::RegCloseKey(hKey);	
				}

				// In the case where this is application/x-unknown-content-type-NetscapeMarkup, 
				// we point .shtml to NetscapeMarkup.
				else if (m_csMimeType == "application/x-unknown-content-type-NetscapeMarkup")
				{
					::RegCreateKeyEx(HKEY_CLASSES_ROOT,
						".shtml", 0L, NULL,
						REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
						&hKey, &dwDisp);
					::RegSetValueEx(hKey, NULL, 0L, REG_SZ,
						(const BYTE *)((const char *)strMARKUP_KEY),
						strMARKUP_KEY.GetLength() + 1);
					::RegCloseKey(hKey);
					
				}

				// In all other cases, we should use the existing file class
				else
				{
					// Need to take over lots of stuff
					CString strType = fileClass;
					if (strType == "NetscapeMarkup")
					  return; // Don't let ANYTHING mess with NetscapeMarkup.
							  // Someone might point something to it later, and
							  // we don't want this code changing the stuff that's already there.

					// Set the open command path
					strValueName.Format(strOPEN_CMD_FMT, (const char *)strType);
					strCmdPath = directoryName + " \"%1\"";
					FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strCmdPath);
		
					// Set the DDE exec value
					strValueName.Format(strDDE_EXEC_FMT, (const char *)strType);
					FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strDDE_EXEC_VALUE);

					// Set the DDE app name
					strValueName.Format(strDDE_APP_FMT, (const char *)strType);
					FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strDDE_APP_NAME);
							
					// Set the DDE topic
					strValueName.Format(strDDE_TOPIC_FMT, (const char *)strType);
					CString strDDETopic;
					strDDETopic.LoadString(IDS_DDE_OPENURL);
					FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strDDETopic);

					// Set the Default Icon
					CString strIconPath;
					CString iconString = ",1";
					if (m_csMimeType == "text/x-javascript" || m_csMimeType == "application/x-javascript")
						iconString = ",7";
					else if (m_csMimeType.Left(5) == "image")
						iconString = ",6";

					strIconPath = CString(buffer) + iconString;
					  
					strValueName.Format(strDEF_ICON_FMT, (const char *)strType);
					FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strIconPath);
				}
			}

			return;
		}
	}

}
Ejemplo n.º 29
0
BOOL 	CWedApp::SaveAllModified()

{
	// Save reopen information:
	CString	buf;
	CPtrList il;
	int		row, col;

    // Save list of buffers
	if(!comline)
    	{
		int count = 0;
		POSITION Pos = pDocTemplate->GetFirstDocPosition();
		// Make a list, current edited buffer as last
		for(;;)
			{
			if(!Pos)
				break;
			CWedDoc* doc = (CWedDoc*)pDocTemplate->GetNextDoc(Pos);
			POSITION pos = doc->GetFirstViewPosition();
			CView *cv = doc->GetNextView(pos); 	ASSERT_VALID(cv);
			if(cv != currentedit)
				il.AddTail(cv);
			}

	if(currentedit)
		il.AddTail(currentedit);

	POSITION pos = il.GetHeadPosition();
	for(;;)
		{
		if(!pos)
			break;
		CView *cv = (CView*)il.GetNext(pos);
		if(!cv)
			break;
		ASSERT_VALID(cv);

		CWedDoc* doc = (CWedDoc*)cv->GetDocument();
		if(!doc)
			break;
		ASSERT_VALID(doc);

		CString fline =doc->strlist.GetLine(0);

		// If it is a new doc
 		if(doc->strlist.GetCount() == 1 &&
			fline.GetLength() == 0)
			{
			//P2N("New doc: %d\r\n",  doc);
			}
		else
			{
			CString file = doc->GetPathName();
			row = ((CWedView*)cv)->row; col = ((CWedView*)cv)->col;
			buf.Format("%d", count + 1);

			WriteProfileString(strSection,  strStringItem + buf, file);
			WriteProfileInt(strSection,  strStringItem + buf + "row", row);
			WriteProfileInt(strSection,  strStringItem + buf + "col", col);
			count++;
			}
		}
	WriteProfileInt(strSection, strIntItem, count);
	}

	// Serialize holdings
	message ("Saving holdings");
	SaveHoldings();

	// Serialize macros
	message ("Saving macros");
	SaveMacros();

	// Save config information:
	CTime t = CTime::GetCurrentTime();
	WriteProfileInt(strConfig, "strLastUsage", (int)t.GetTime());
	WriteProfileInt(strConfig, "strUsage", use);

	// Save main frame window placement
	WINDOWPLACEMENT wp;
	pMainFrame->GetWindowPlacement(&wp);
	WriteProfileInt(strConfig, "WindowState",  wp.showCmd);
	// Save file informaion

	// Save current window focus:

	// Save font info
    LOGFONT lf; ff.GetObject(sizeof(LOGFONT), &lf);
	WriteProfileString(strConfig,  strFontName, lf.lfFaceName);
	WriteProfileInt(strConfig,  strFontSize, lf.lfHeight);
	WriteProfileInt(strConfig,  strFontWeight, lf.lfWeight);
	WriteProfileInt(strConfig,  strFontItalic, lf.lfItalic);

	// Save color info
	WriteProfileInt(strConfig,  strColorBg, 	bgcol);
	WriteProfileInt(strConfig,  strColorFg, 	fgcol);
	WriteProfileInt(strConfig,  strColorSel , 	selcol );
    WriteProfileInt(strConfig,  strColorCSel, 	cselcol);
    WriteProfileInt(strConfig,  strColorAdd , 	cadd   );
    WriteProfileInt(strConfig,  strColorDel , 	cdel   );
    WriteProfileInt(strConfig,  strColorChg , 	cchg   );
    WriteProfileInt(strConfig,  strColorComm, 	comm   );
    WriteProfileInt(strConfig,  strColorSrc , 	srcc   );
    WriteProfileInt(strConfig,  strColorLong , 	clng   );

	// Save backwrap
	WriteProfileInt(strConfig,  strBackWrap , backwrap);

	// Save tab2space
	WriteProfileInt(strConfig,  strTab2Space, Tab2Space);

	// Save tabstop
	WriteProfileInt(strConfig,  strTabStop, tabstop);




	return CWinApp::SaveAllModified();
}
Ejemplo n.º 30
0
BOOL CUpdateUtil::CompareFileVersion2(CItemList *pItemListSourceCmp, CItemList *pItemListDestCmp)
{
	CPtrList* pPLClient = pItemListDestCmp->GetPtrList();
	CPtrList* pPLServer = pItemListSourceCmp->GetPtrList();
	BOOL bExist = FALSE;
	UPDATE_DATA *psiServer = NULL;
	UPDATE_DATA *psiClient = NULL;
	CString strFilePath = "";

	UTIL_CANCEL();
	// Client xml File check
	POSITION posClient = pPLClient->GetHeadPosition();
	while(posClient)
	{	
		bExist = FALSE;
		psiClient = (UPDATE_DATA *)pPLClient->GetNext(posClient);
		
		UTIL_CANCEL();
		POSITION posServer= pPLServer->GetHeadPosition();
		while(posServer)
		{		
			psiServer = (UPDATE_DATA *)pPLServer->GetNext(posServer);
			if(strcmp(psiClient->Name, psiServer->Name) == 0){
				bExist = TRUE;
				strFilePath.Format("%s\\%s", psiClient->DownPath, psiClient->Name);
				
				UTIL_CANCEL();
				switch (VersionCheck(strFilePath, psiClient->Version, psiServer->Version, psiServer->DownURL, psiServer->CheckSum, psiServer->Size))
				{
				case UPDATE_FLAG_NORMAL:
					TRACE("%s File : Do not anything  because %s == %s\n", strFilePath, psiClient->Version, psiServer->Version);
					psiServer->UpdateFlag = UPDATE_FLAG_NORMAL;
					break;
				case UPDATE_FLAG_NEW:
					TRACE("%s File : New  because not exsist\n", strFilePath);
					psiServer->UpdateFlag = UPDATE_FLAG_NEW;
					break;
				case UPDATE_FLAG_UPDATE:
					TRACE("%s File : Update  because %s < %s\n", strFilePath, psiClient->Version, psiServer->Version);
					psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
					break;
				case UPDATE_FLAG_DIFFERENT:
					TRACE("%s File : Update because different between xml version file and exist file\n", strFilePath);
					psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
					break;
				}
			}
			
			if(bExist)
				break;
		}
		
		if(!bExist){
			TRACE("%s File : Delete\n", psiClient->Name);
			psiClient->UpdateFlag = UPDATE_FLAG_DELETE;
		}
	
	}

	UTIL_CANCEL();
	// Server xml File check
	POSITION posServer= pPLServer->GetHeadPosition();
	while(posServer)
	{	
		bExist = FALSE;
		psiServer = (UPDATE_DATA *)pPLServer->GetNext(posServer);
		
		if(strcmp(psiServer->Force, UPDATE_FORCE) == 0){
			TRACE("%s File : Update because forced\n", psiServer->Name);
			psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
			continue;
		}
		
		UTIL_CANCEL();
		POSITION posClient = pPLClient->GetHeadPosition();
		while(posClient)
		{	
			psiClient = (UPDATE_DATA *)pPLClient->GetNext(posClient);	
			if(strcmp(psiClient->Name, psiServer->Name) == 0){
				bExist = TRUE;
				if(psiServer->UpdateFlag == 0){					
					UTIL_CANCEL();
					strFilePath.Format("%s\\%s", psiServer->DownPath, psiServer->Name);
					switch (VersionCheck(strFilePath, psiClient->Version, psiServer->Version, psiServer->DownURL, psiServer->CheckSum, psiServer->Size))
					{
					case UPDATE_FLAG_NORMAL:
						TRACE("%s File : Do not anything  because %s == %s\n", strFilePath, psiClient->Version, psiServer->Version);
						psiServer->UpdateFlag = UPDATE_FLAG_NORMAL;
						break;
					case UPDATE_FLAG_NEW:
						TRACE("%s File : New  because not exsist\n", strFilePath);
						psiServer->UpdateFlag = UPDATE_FLAG_NEW;
						break;
					case UPDATE_FLAG_UPDATE:
						TRACE("%s File : Update  because %s < %s\n", strFilePath, psiClient->Version, psiServer->Version);
						psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
						break;
					case UPDATE_FLAG_DIFFERENT:
						TRACE("%s File : Update because different between xml version file and exist file\n", strFilePath);
						psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
						break;
					}
				}
		
				break;
			}
		}			

		if(!bExist){
			TRACE("%s File : new\n", psiServer->Name);
			psiServer->UpdateFlag = UPDATE_FLAG_NEW;
		}
	}

	// last server update new file check
	UTIL_CANCEL();
	posServer= pPLServer->GetHeadPosition();
	while(posServer)
	{	
		psiServer = (UPDATE_DATA *)pPLServer->GetNext(posServer);
		
		UTIL_CANCEL();
		if(psiServer->UpdateFlag == UPDATE_FLAG_NEW){
			strFilePath.Format("%s\\%s", psiServer->DownPath, psiServer->Name);
			switch (VersionCheck(strFilePath, "0", psiServer->Version, psiServer->DownURL, psiServer->CheckSum, psiServer->Size))
			{
			case UPDATE_FLAG_NORMAL:
				TRACE("%s File : Do not anything  because %s == %s\n", strFilePath, psiServer->Version, psiServer->Version);
				psiServer->UpdateFlag = UPDATE_FLAG_NORMAL;
				break;
			case UPDATE_FLAG_NEW:
				TRACE("%s File : New  because not exsist\n", strFilePath);
				psiServer->UpdateFlag = UPDATE_FLAG_NEW;
				break;
			case UPDATE_FLAG_UPDATE:
				TRACE("%s File : Update  because %s < %s\n", strFilePath, psiServer->Version, psiServer->Version);
				psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
				break;
			case UPDATE_FLAG_DIFFERENT:
				TRACE("%s File : Update because different between xml version file and exist file\n", strFilePath);
				psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
				break;
			}
		}
	}

	return TRUE;
}