示例#1
0
STDMETHODIMP SkinMgr::LoadTheme(LPCSTR file)
{
    ASSERT(file);

    // 1 尝试绝对路径
    char path[MAX_PATH];
    lstrcpyn(path, file, MAX_PATH);
    if (!PathFileExists(path))
    {
        // 相对路径
        GetCurrentDirectory(MAX_PATH, path);
        PathAppend(path, file);
    }
    
    bool f = false;
    if (file && _holder.parse_scheme(path))
    {
        f = true;
        _spCurrentScheme.Release();
        GetScheme("default", &_spCurrentScheme);

        ASSERT(_spCurrentScheme);
    }
    return f ? S_OK : E_FAIL;
}
示例#2
0
文件: NURL.cpp 项目: refnum/nano
//============================================================================
//		NURL::GetPort : Get the port.
//----------------------------------------------------------------------------
NIndex NURL::GetPort(void) const
{	NString		theValue, theScheme;
	NNumber		theNumber;
	NIndex		theResult;



	// Get the port
	theValue  = GetToken("^\\w+://.*?:(\\d+)/");
	theResult = kNIndexNone;

	if (!theValue.IsEmpty() && theNumber.SetValue(theValue))
		theResult = theNumber.GetInt32();



	// Provide some defaults
	if (theResult == kNIndexNone)
		{
		theScheme = GetScheme();
		
		if (theScheme == "http")
			theResult = 80;

		else if (theScheme == "https")
			theResult = 443;

		else if (theScheme == "ssh")
			theResult = 22;
		}

	return(theResult);
}
示例#3
0
static DmtxBoolean
ValidStateSwitch(int fromState, int targetState)
{
   DmtxBoolean validStateSwitch;
   DmtxScheme fromScheme = GetScheme(fromState);
   DmtxScheme toScheme = GetScheme(targetState);

   if(fromScheme == toScheme && fromState != targetState &&
         fromState != AsciiFull && targetState != AsciiFull)
   {
      validStateSwitch = DmtxFalse;
   }
   else
   {
      validStateSwitch = DmtxTrue;
   }

   return validStateSwitch;
}
NS_IMETHODIMP
nsNntpUrl::GetServer(nsIMsgIncomingServer **aServer)
{
  NS_ENSURE_ARG_POINTER(aServer);
  
  nsresult rv;
  nsAutoCString scheme, user, host;

  GetScheme(scheme);
  GetUsername(user);
  GetHost(host);

  // No authority -> no server
  if (host.IsEmpty())
  {
    *aServer = nullptr;
    return NS_OK;
  }

  // Looking up the server...
  // news-message is used purely internally, so it can never refer to the real
  // attribute. nntp is never used internally, so it probably refers to the real
  // one. news is used both internally and externally, so it could refer to
  // either one. We'll assume it's an internal one first, though.
  bool isNews = scheme.EqualsLiteral("news") || scheme.EqualsLiteral("snews");
  bool isNntp = scheme.EqualsLiteral("nntp") || scheme.EqualsLiteral("nntps");
  
  bool tryReal = isNntp;

  nsCOMPtr<nsIMsgAccountManager> accountManager = 
    do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  // Ignoring return results: it is perfectly acceptable for the server to not
  // exist, but FindServer (and not FindRealServer) throws NS_ERROR_UNEXPECTED
  // in this case.
  *aServer = nullptr;
  if (tryReal)
    accountManager->FindRealServer(user, host, NS_LITERAL_CSTRING("nntp"), 0,
      aServer);
  else
    accountManager->FindServer(user, host, NS_LITERAL_CSTRING("nntp"), aServer);
  if (!*aServer && (isNews || isNntp))
  {
    // Didn't find it, try the other option
    if (tryReal)
      accountManager->FindServer(user, host, NS_LITERAL_CSTRING("nntp"),
        aServer);
    else
      accountManager->FindRealServer(user, host, NS_LITERAL_CSTRING("nntp"), 0,
        aServer);
  }
  return NS_OK;
}
//-----------------------------------------------------------------------------
// Purpose: Determine text size ahead of time
// Input  : *wide - 
//			*tall - 
//			*string - 
//-----------------------------------------------------------------------------
void CMessageCharsPanel::GetTextExtents( vgui::HFont hCustomFont, int *wide, int *tall, const char *string )
{
	if ( !hCustomFont )
	{
		// Make sure we actually have the font...
		vgui::IScheme *pScheme = vgui::scheme()->GetIScheme( GetScheme() );
		hCustomFont = pScheme->GetFont( "Default" );
	}

	Assert( hCustomFont );

	*wide = g_pMatSystemSurface->DrawTextLen( hCustomFont, (char *)string );
	*tall = vgui::surface()->GetFontTall( hCustomFont );
}
示例#6
0
void CHudCloseCaption::CreateFonts( void )
{
    vgui::IScheme *pScheme = vgui::scheme()->GetIScheme( GetScheme() );

    fontSet[ FONT_NORMAL ]				= pScheme->GetFont( "CloseCaption_Normal" );
    fontSet[ FONT_BOLD ]				= pScheme->GetFont( "CloseCaption_Bold" );
    fontSet[ FONT_ITALIC ]				= pScheme->GetFont( "CloseCaption_Italic" );
    fontSet[ FONT_BOLD | FONT_ITALIC ]	= pScheme->GetFont( "CloseCaption_BoldItalic" );

    Assert( fontSet[ FONT_NORMAL ] );
    Assert( fontSet[ FONT_BOLD ] );
    Assert( fontSet[ FONT_ITALIC ] );
    Assert( fontSet[ FONT_BOLD | FONT_ITALIC ] );
}
NS_IMETHODIMP MsgMailNewsUrlBase::GetServer(nsIMsgIncomingServer ** aIncomingServer)
{
  // mscott --> we could cache a copy of the server here....but if we did, we run
  // the risk of leaking the server if any single url gets leaked....of course that
  // shouldn't happen...but it could. so i'm going to look it up every time and
  // we can look at caching it later.

  nsresult rv;
  nsAutoCString urlstr;
  nsAutoCString scheme;

  nsCOMPtr<nsIURL> url = do_CreateInstance(NS_STANDARDURL_CONTRACTID, &rv);
  if (NS_FAILED(rv)) return rv;

  m_baseURL->GetSpec(urlstr);
  rv = url->SetSpec(urlstr);
  if (NS_FAILED(rv)) return rv;
  rv = GetScheme(scheme);
    if (NS_SUCCEEDED(rv))
    {
        if (scheme.EqualsLiteral("pop"))
          scheme.Assign("pop3");
        // we use "nntp" in the server list so translate it here.
        if (scheme.EqualsLiteral("news"))
          scheme.Assign("nntp");
        url->SetScheme(scheme);
        nsCOMPtr<nsIMsgAccountManager> accountManager = 
                 do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
        if (NS_FAILED(rv)) return rv;
        
        nsCOMPtr<nsIMsgIncomingServer> server;
        rv = accountManager->FindServerByURI(url, false,
                                        aIncomingServer);
        if (!*aIncomingServer && scheme.EqualsLiteral("imap"))
        {
          // look for any imap server with this host name so clicking on 
          // other users folder urls will work. We could override this method
          // for imap urls, or we could make caching of servers work and
          // just set the server in the imap code for this case.
          url->SetUserPass(EmptyCString());
          rv = accountManager->FindServerByURI(url, false,
                                          aIncomingServer);
        }
    }

    return rv;
}
NS_IMETHODIMP nsNntpUrl::SetSpec(const nsACString &aSpec)
{
  // For [s]news: URIs, we need to munge the spec if it is no authority, because
  // the URI parser guesses the wrong thing otherwise
  nsCString parseSpec(aSpec);
  int32_t colon = parseSpec.Find(":");

  // Our smallest scheme is 4 characters long, so colon must be at least 4
  if (colon < 4 || colon + 1 == (int32_t) parseSpec.Length())
    return NS_ERROR_MALFORMED_URI;

  if (Substring(parseSpec, colon - 4, 4).EqualsLiteral("news") &&
      parseSpec[colon + 1] != '/')
  {
    // To make this parse properly, we add in three slashes, which convinces the
    // parser that the authority component is empty.
    parseSpec = Substring(aSpec, 0, colon + 1);
    parseSpec.AppendLiteral("///");
    parseSpec += Substring(aSpec, colon + 1);
  }

  nsresult rv = nsMsgMailNewsUrl::SetSpec(parseSpec);
  NS_ENSURE_SUCCESS(rv,rv);

  nsAutoCString scheme;
  rv = GetScheme(scheme);
  NS_ENSURE_SUCCESS(rv, rv);

  if (scheme.EqualsLiteral("news") || scheme.EqualsLiteral("snews"))
    rv = ParseNewsURL();
  else if (scheme.EqualsLiteral("nntp") || scheme.EqualsLiteral("nntps"))
    rv = ParseNntpURL();
  else if (scheme.EqualsLiteral("news-message"))
  {
    nsAutoCString spec;
    GetSpec(spec);
    rv = nsParseNewsMessageURI(spec.get(), m_group, &m_key);
    NS_ENSURE_SUCCESS(rv, NS_ERROR_MALFORMED_URI);
  }
  else
    return NS_ERROR_MALFORMED_URI;
  NS_ENSURE_SUCCESS(rv, rv);

  rv = DetermineNewsAction();
  NS_ENSURE_SUCCESS(rv,rv);
  return rv;
}
void CDialog_PPEPrecache::FillList()
{
	ScrollBar *pScroll = m_pList_Effects->GetScrollbar();
	int scrollValue = pScroll ? pScroll->GetValue() : 0;

	m_pList_Effects->DeleteAllItems();

	GetPPCache()->ClearInvalidEntries();

	HFont fontMarlett = scheme()->GetIScheme( GetScheme() )->GetFont( "Marlett", false );

	for ( int i = 0; i < GetPPCache()->GetNumPostProcessingEffects(); i++ )
	{
		EditorPostProcessingEffect *effect = GetPPCache()->GetPostProcessingEffect( i );

		Label *pL = new Label( m_pList_Effects, "", effect->pszName );
		Button *pDel = new Button( m_pList_Effects, "", "Delete", this, VarArgs("del_effect_%i",i) );
		CheckButton *pCheck = new CheckButton( m_pList_Effects, effect->pszName, "" );

		pCheck->AddActionSignalTarget( this );
		pCheck->SetSelected( effect->bStartEnabled );

		Button *pDown = new Button( m_pList_Effects, "", "u", this, VarArgs("movedown_effect_%i",i) );
		Button *pUp = new Button( m_pList_Effects, "", "t", this, VarArgs("moveup_effect_%i",i) );

		pDown->SetFont( fontMarlett );
		pUp->SetFont( fontMarlett );

		pDel->SetContentAlignment( Label::a_center );
		pDown->SetContentAlignment( Label::a_center );
		pUp->SetContentAlignment( Label::a_center );

		m_pList_Effects->AddItem( NULL, pCheck );
		m_pList_Effects->AddItem( NULL, pDown );
		m_pList_Effects->AddItem( NULL, pUp );
		m_pList_Effects->AddItem( pL, pDel );
	}

	if ( pScroll )
		pScroll->SetValue( scrollValue );
}
示例#10
0
/**
 * It's safe to compare output length because all targetState combinations
 * start on same input and encodes same number of inputs. Only difference
 * is the number of latches/unlatches that are also encoded
 */
static void
StreamAdvanceFromBest(DmtxEncodeStream *streamsNext, DmtxEncodeStream *streamsBest,
     int targetState, int sizeIdxRequest)
{
   enum SchemeState fromState;
   DmtxScheme targetScheme;
   DmtxEncodeOption encodeOption;
   DmtxByte outputTempStorage[4096];
   DmtxByteList outputTemp = dmtxByteListBuild(outputTempStorage, sizeof(outputTempStorage));
   DmtxEncodeStream streamTemp;
   DmtxEncodeStream *targetStream = &(streamsNext[targetState]);

   streamTemp.output = &outputTemp; /* Set directly instead of calling StreamInit() */
   targetScheme = GetScheme(targetState);

   if(targetState == AsciiFull)
      encodeOption = DmtxEncodeFull;
   else if(targetState == AsciiCompactOffset0 || targetState == AsciiCompactOffset1)
      encodeOption = DmtxEncodeCompact;
   else
      encodeOption = DmtxEncodeNormal;

   for(fromState = 0; fromState < SchemeStateCount; fromState++)
   {
      if(streamsBest[fromState].status != DmtxStatusEncoding ||
            ValidStateSwitch(fromState, targetState) == DmtxFalse)
      {
         continue;
      }

      StreamCopy(&streamTemp, &(streamsBest[fromState]));
      EncodeNextChunk(&streamTemp, targetScheme, encodeOption, sizeIdxRequest);

      if(fromState == 0 || (streamTemp.status != DmtxStatusInvalid &&
            streamTemp.output->length < targetStream->output->length))
      {
         StreamCopy(targetStream, &streamTemp);
      }
   }
}
示例#11
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
Color CHudChat::GetTextColorForClient( TextColor colorNum, int clientIndex )
{
	IScheme *pScheme = scheme()->GetIScheme( GetScheme() );

	if ( pScheme == NULL )
		return Color( 255, 255, 255, 255 );

	Color c;
	switch ( colorNum )
	{
	case COLOR_PLAYERNAME:
		c = GetClientColor( clientIndex );
		break;

	case COLOR_LOCATION:
		c = g_ColorDarkGreen;
		break;

	case COLOR_ACHIEVEMENT:
		{
			IScheme *pSourceScheme = scheme()->GetIScheme( scheme()->GetScheme( "SourceScheme" ) ); 
			if ( pSourceScheme )
			{
				c = pSourceScheme->GetColor( "SteamLightGreen", GetBgColor() );
			}
			else
			{
				c = pScheme->GetColor( "TFColors.ChatTextYellow", GetBgColor() );
			}
		}
		break;

	default:
		c = pScheme->GetColor( "TFColors.ChatTextYellow", GetBgColor() );
	}

	return Color( c[0], c[1], c[2], 255 );
}
示例#12
0
//-----------------------------------------------------------------------------
Color CHudChat::GetClientColor( int clientIndex )
{
	IScheme *pScheme = scheme()->GetIScheme( GetScheme() );

	if ( pScheme == NULL )
		return Color( 255, 255, 255, 255 );

	if ( clientIndex == 0 ) // console msg
	{
		return g_ColorGreen;
	}
	else if( g_PR )
	{
		int iTeam = g_PR->GetTeam( clientIndex );

		C_TFPlayer *pPlayer = ToTFPlayer( UTIL_PlayerByIndex( clientIndex ) );
		C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();

		if ( IsVoiceSubtitle() == true )
		{
			// if this player is on the other team, disguised as my team, show disguised color
			if ( pPlayer && pLocalPlayer && pPlayer->m_Shared.InCond( TF_COND_DISGUISED ) &&
				pPlayer->m_Shared.GetDisguiseTeam() == pLocalPlayer->GetTeamNumber() )
			{
				iTeam = pPlayer->m_Shared.GetDisguiseTeam();
			}
		}

		switch ( iTeam )
		{
		case TF_TEAM_RED	: return pScheme->GetColor( "TFColors.ChatTextRed", g_ColorRed );
		case TF_TEAM_BLUE	: return pScheme->GetColor( "TFColors.ChatTextBlue", g_ColorBlue );;
		default	: return g_ColorGrey;
		}
	}

	return g_ColorYellow;
}
nsresult
SubstitutingURL::EnsureFile()
{
  nsAutoCString ourScheme;
  nsresult rv = GetScheme(ourScheme);
  NS_ENSURE_SUCCESS(rv, rv);

  // Get the handler associated with this scheme. It would be nice to just
  // pass this in when constructing SubstitutingURLs, but we need a generic
  // factory constructor.
  nsCOMPtr<nsIIOService> io = do_GetIOService(&rv);
  nsCOMPtr<nsIProtocolHandler> handler;
  rv = io->GetProtocolHandler(ourScheme.get(), getter_AddRefs(handler));
  NS_ENSURE_SUCCESS(rv, rv);
  nsCOMPtr<nsISubstitutingProtocolHandler> substHandler = do_QueryInterface(handler);
  MOZ_ASSERT(substHandler);

  nsAutoCString spec;
  rv = substHandler->ResolveURI(this, spec);
  if (NS_FAILED(rv))
    return rv;

  nsAutoCString scheme;
  rv = net_ExtractURLScheme(spec, nullptr, nullptr, &scheme);
  if (NS_FAILED(rv))
    return rv;

  // Bug 585869:
  // In most cases, the scheme is jar if it's not file.
  // Regardless, net_GetFileFromURLSpec should be avoided
  // when the scheme isn't file.
  if (!scheme.EqualsLiteral("file"))
    return NS_ERROR_NO_INTERFACE;

  return net_GetFileFromURLSpec(spec, getter_AddRefs(mFile));
}
示例#14
0
//---------------------------------------------------------------------------
int __fastcall TThdSend::GetFromQue()
{
  TBourse bourse;
  while(!FQueSend->empty()){
    if(!FQueSend->front()->StartTrd){                        //收到停止交易信号
//      int pos = FindInLocal(FQueSend->front()->SecuID,FQueSend->front()->PtfName,FQueSend->front()->AccountInfo);
      int pos = FindInLocal(FInSend,FQueSend->front());
      if(pos>=0){
        TLocalDtl *l  = ((TLocalDtl*)FLocalDtl->Items[pos]);
        TItfTrd   *it = (TItfTrd *)(FItfTrdLst->Items[l->ItfTrdPos]);
        if(l->SecuID.SubString(1,1).UpperCase() == "S") bourse = bsSZ;
        else bourse = bsSH;

        for(int j=0;j<l->TrdInfo->Count;j++){                         //全部撤单
          TTrdInfo  *t         = (TTrdInfo *)(l->TrdInfo->Items[j]);
          String    ContractID = t->ContractID;
          
          if(it->Undo(ContractID,bourse)<-1) {
            FErrMsg = "成交完成后撤单未成功,合同号:" + ContractID;
            Synchronize(ShowErr);
          }
        }
        ((TQueItf*)FInSend->Items[l->Locate])->State = tsStop;        //设置停止状态

        FErrMsg = "对股票" + l->SecuID + " 派发已经停止,成交量为" + IntToStr(l->CurVol+l->LastVol) + "股,剩余量为"+IntToStr(l->TotalVol-l->CurVol-l->LastVol)+ "股";
        Synchronize(ShowErr);
        DeleteTrd(pos);                                                  //从本地列表中删除
      }
//      delete FQueSend->front();
      FQueSend->pop();
      continue;
    }

    TScheme *s = new TScheme();
    CoInitialize(NULL);
    if(GetScheme(s,FQueSend->front()->Scheme)==-1){
      FErrMsg = String(FQueSend->front()->Scheme)+"方案信息读取错误";
      Synchronize(ShowErr);
      delete s;
      FQueSend->front()->State = tsStop;
      FQueSend->pop();  continue;
    }
    CoUninitialize();
    
    TLocalDtl *dtl  = new TLocalDtl();
    dtl->SecuID     = FQueSend->front()->SecuID;
    dtl->PtfName    = FQueSend->front()->PtfName;
    dtl->LastTime   = time(NULL);

    if(s->TrdSec < 0){                     //按行情刷新保存最新价
      dtl->TrdX = TRjlFunc::StrToDouble(TRjlSysVar()()->DatDyn->GetField(TRjlSysVar()()->DatDyn->GetLoc(dtl->SecuID),dtCp));
    }
    else if(s->TrdSec == 0) dtl->TrdX = random(s->Sec2-s->Sec1)+s->Sec1;     //随机时间下单保存随机时间

    dtl->QryTime    = time(NULL);
    dtl->LastVol    = FQueSend->front()->CurVol;
    dtl->CurVol     = 0;
    dtl->LastPrc    = FQueSend->front()->CurVol * FQueSend->front()->AvgPrice;
    dtl->TotalVol   = FQueSend->front()->Vol;
    dtl->Scheme     = s;
    dtl->PriceLimit = FQueSend->front()->PriceLimit;
    dtl->VolLimit   = FQueSend->front()->VolLimit;
    dtl->TrdInfo    = new TList();
    dtl->TrdInfo->Clear();

    FQueSend->front()->State = tsRunning;                  //置状态
    FInSend->Add(FQueSend->front());                       //将队列中的结构指针转移到FInSend中保存
    dtl->Locate = FInSend->Count-1;                        //位置从0开始

    int ItfTrdPos = FindItfTrd(FQueSend->front()->AccountInfo); //查找该账号的交易接口指针是否已经存在
    if(ItfTrdPos == -1){                                   //若不存在,新增该交易接口指针,加到交易接口列表中
      CoInitialize(NULL);
      TItfTrd *it = new TItfTrd();
      it->Init("","");
      CoUninitialize();
      if(it->SetAccInfo(&(FQueSend->front()->AccountInfo))<0){
        FQueSend->pop() ;
        delete it; delete dtl->Scheme; delete dtl->TrdInfo;delete dtl;
        return 0;
      }
      ItfTrdPos   = FItfTrdLst->Add(it);
    }
    dtl->ItfTrdPos = ItfTrdPos;                            //在本地列表中记录该接口指针在接口列表中的位置,以便切换

    FLocalDtl->Add(dtl);                                   //加到本地列表中

    FQueSend->pop() ;
  }
  
  return 0;
}
 void ExplicitSolverStrategy::PerformTimeIntegrationOfMotion(int StepFlag) {
     KRATOS_TRY
     GetScheme()->Calculate(GetModelPart(), StepFlag);
     GetScheme()->Calculate(*mpCluster_model_part, StepFlag);
     KRATOS_CATCH("")
 }