• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sMsg函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sMsg函数的典型用法代码示例。如果您正苦于以下问题:C++ sMsg函数的具体用法?C++ sMsg怎么用?C++ sMsg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sMsg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: SetCheckpointPrivKey

    bool SetCheckpointPrivKey(std::string strPrivKey)
    {
        // Test signing a sync-checkpoint with genesis block
        CSyncCheckpoint checkpoint;
        checkpoint.hashCheckpoint = !fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet;
        CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION);
        sMsg << (CUnsignedSyncCheckpoint)checkpoint;
        checkpoint.vchMsg = std::vector<unsigned char>(sMsg.begin(), sMsg.end());

        std::vector<unsigned char> vchPrivKey = ParseHex(strPrivKey);
        CKey key;
        key.SetPrivKey(CPrivKey(vchPrivKey.begin(), vchPrivKey.end())); // if key is not correct openssl may crash
        if (!key.Sign(Hash(checkpoint.vchMsg.begin(), checkpoint.vchMsg.end()), checkpoint.vchSig))
            return false;

        // Test signing successful, proceed
        CSyncCheckpoint::strMasterPrivKey = strPrivKey;
        return true;
    }
开发者ID:coinkeeper,项目名称:2015-04-19_21-16_halcyon,代码行数:19,代码来源:checkpoints.cpp


示例2: sMsg

int CMDIfileManager::_RemoveWindowFromAList(CMDI_LIST *pList,CMDIFrame *p)
{
  CMDI_LIST::iterator itr;
  CMDI_LIST::iterator itrEnd = pList->end();
  int nRtn = 0;
  for(itr = pList->begin();
      (itr != itrEnd) && (p != *itr);
       ++itr)  {;}
  if(itr != itrEnd)
  {
    pList->erase(itr);
    nRtn = 1;
  }
  else
  {
    wxString sMsg(wxS("CMDIfileManager::_RemoveWindowFromAList - did not find window"));
    wxASSERT_MSG(0,sMsg);
  }
  return nRtn;
}
开发者ID:ncbi,项目名称:osiris,代码行数:20,代码来源:CMDIfileManager.cpp


示例3: ASSERT

void CUse3Dlg::OnBnClickedButton6()		// 智能指针的释放
{
	::CoInitialize( NULL );		// 如果在这里进行 COM 初始化,要注意智能指针的释放

	CComQIPtr < IFun, &IID_IFun > spFun;

	HRESULT hr = spFun.CoCreateInstance( CLSID_Fun );
	ASSERT( SUCCEEDED( hr ) );
	// 为了简单起见,不再使用 if 判断 HRESULT 了。IFun::Add() 也没有调用

	CComBSTR s1( "Hello" ), s2( " world" ), s3;
	hr = spFun->Cat( s1, s2, &s3 );
	ASSERT( SUCCEEDED( hr ) );
	CString sMsg( s3 );
	AfxMessageBox( sMsg );

//	spFun->Release();	// 大错特错!!!
	spFun.Release();	// 正解

	::CoUninitialize();
}
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:21,代码来源:Use3Dlg.cpp


示例4: GetDM5RegistryKey

bool Registrar::CreateEventHandlerKey()
{
	CRegKey reg;
	CStdString sKey = GetDM5RegistryKey();
	LONG lRes = reg.Create(HKEY_LOCAL_MACHINE, sKey.c_str());

	if (lRes == ERROR_SUCCESS)
	{
		reg.Close();
		return true;
	}
	else
	{
		CStdString sMsg(_T("Unable to Create registry key with the following information"));
		sMsg += _T(" KEY: ") + sKey;
		sMsg += _T(" Error: ") + DecodeError(lRes);
		LOG_WS_ERROR(sMsg.c_str());
	}

	return false;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:21,代码来源:Registrar.cpp


示例5: SetCheckpointPrivKey

    bool SetCheckpointPrivKey(std::string strPrivKey)
    {
        // Test signing a sync-checkpoint with genesis block
        CSyncCheckpoint checkpoint;
        checkpoint.hashCheckpoint = hashGenesisBlock;
        CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION);
        sMsg << (CUnsignedSyncCheckpoint)checkpoint;
        checkpoint.vchMsg = std::vector<unsigned char>(sMsg.begin(), sMsg.end());

        CBitcoinSecret vchSecret;
        if (!vchSecret.SetString(strPrivKey))
            return error("SendSyncCheckpoint: Checkpoint master key invalid");
        CKey key;
        bool fCompressed;
        CSecret secret = vchSecret.GetSecret(fCompressed);
        key.SetSecret(secret, fCompressed); // if key is not correct openssl may crash
        if (!key.Sign(Hash2(checkpoint.vchMsg.begin(), checkpoint.vchMsg.end()), checkpoint.vchSig))
            return false;

        // Test signing successful, proceed
        CSyncCheckpoint::strMasterPrivKey = strPrivKey;
        return true;
    }
开发者ID:mine-pool,项目名称:secondscoin,代码行数:23,代码来源:checkpoints.cpp


示例6: GetLockFileName

bool nwxLockFile::Unlock(const wxString &sFileName)
{
  set<wxString>::iterator itr = m_setFileName.find(sFileName);
  bool bRtn = false;
  if(itr != m_setFileName.end())
  {
    wxString sFileLockName = GetLockFileName(sFileName);
    bRtn = true; // file was locked by this instance
    if(!wxFileExists(sFileLockName)) {;} // OK
    else if(!wxRemoveFile(sFileLockName))
    {
      // have a problem removing this file, log the error and still return true
      time_t t;
      time(&t);
      wxString sMsg(_T("Cannot remove lock file: "));
      sMsg.Append(sFileLockName);
      wxLog::OnLog(wxLOG_Message,(const wxChar *)sMsg,t);
      wxASSERT_MSG(false,sMsg);
    }
    m_setFileName.erase(itr);
  }
  return bRtn;
}
开发者ID:mdavis45419,项目名称:osiris,代码行数:23,代码来源:nwxLockFile.cpp


示例7: MRetToPoint

bool cGameCell::ContainsObject( cGameEnt* pObj )
{
	int i;
	point3 loc = MRetToPoint( pObj->ProcMsg( sMsg( msgGetLoc ) ) );
	float radius = 2.f;

	// FIXME: not checking to see if we're inside a portal.
	for( i=0; i<m_polyList.size(); i++ )
	{
		if( ptBack == m_polyList[i].m_plane.TestPoint(loc) )
		{
			return false;
		}
	}
	for( i=0; i<m_portalList.size(); i++ )
	{
		if( ptBack == m_portalList[i].m_plane.TestPoint(loc) )
		{
			return false;
		}
	}
	return true;
}
开发者ID:amitahire,项目名称:development,代码行数:23,代码来源:GameCell.cpp


示例8: SendSyncCheckpoint

    bool SendSyncCheckpoint(uint256 hashCheckpoint)
    {
        CSyncCheckpoint checkpoint;
        checkpoint.hashCheckpoint = hashCheckpoint;
        CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION);
        sMsg << (CUnsignedSyncCheckpoint)checkpoint;
        checkpoint.vchMsg = std::vector<unsigned char>(sMsg.begin(), sMsg.end());

        if (CSyncCheckpoint::strMasterPrivKey.empty())
            return error("SendSyncCheckpoint: Checkpoint master private key unavailable.");

        std::vector<unsigned char> vchPrivKey = ParseHex(CSyncCheckpoint::strMasterPrivKey);
        CKey key;

        // if key is not correct openssl may crash
        key.Set(vchPrivKey.begin(), vchPrivKey.end(), false);
        if (!key.IsValid())
            return error("SendSyncCheckpoint: failed to set private key.");

        if (!key.Sign(Hash(checkpoint.vchMsg.begin(), checkpoint.vchMsg.end()), checkpoint.vchSig))
            return error("SendSyncCheckpoint: Unable to sign checkpoint, check private key?");

        if(!checkpoint.ProcessSyncCheckpoint(NULL))
        {
            printf("WARNING: SendSyncCheckpoint: Failed to process checkpoint.\n");
            return false;
        }

        printf("SendSyncCheckpoint: about to relay checkpoint.\n");
        // Relay checkpoint
        {
            LOCK(cs_vNodes);
            BOOST_FOREACH(CNode* pnode, vNodes)
                checkpoint.RelayTo(pnode);
        }
        return true;
    }
开发者ID:Andrey777Virus,项目名称:reddcoin,代码行数:37,代码来源:checkpoints.cpp


示例9: SendSyncCheckpoint

    bool SendSyncCheckpoint(uint256 hashCheckpoint)
    {
        LogPrintf("SendSyncCheckpoint: hashCheckpoint=%s\n", hashCheckpoint.ToString().c_str());
        
        CSyncCheckpoint checkpoint;
        checkpoint.hashCheckpoint = hashCheckpoint;
        CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION);
        sMsg << (CUnsignedSyncCheckpoint)checkpoint;
        checkpoint.vchMsg = std::vector<unsigned char>(sMsg.begin(), sMsg.end());

        if (CSyncCheckpoint::strMasterPrivKey.empty())
            return error("SendSyncCheckpoint: Checkpoint master key unavailable.");
        CBitcoinSecret vchSecret;
        if (!vchSecret.SetString(CSyncCheckpoint::strMasterPrivKey))
            return error("SendSyncCheckpoint: Checkpoint master key invalid");
        // bool fCompressed;
        // CSecret secret = vchSecret.GetSecret(fCompressed);
        CKey secret = vchSecret.GetKey();
        // key.SetSecret(secret, fCompressed); // if key is not correct openssl may crash
        CKey key(secret);
        if (!key.Sign(Hash(checkpoint.vchMsg.begin(), checkpoint.vchMsg.end()), checkpoint.vchSig))
            return error("SendSyncCheckpoint: Unable to sign checkpoint, check private key?");

        if(!checkpoint.ProcessSyncCheckpoint(NULL))
        {
            LogPrintf("WARNING: SendSyncCheckpoint: Failed to process checkpoint.\n");
            return false;
        }

        // Relay checkpoint
        {
            LOCK(cs_vNodes);
            BOOST_FOREACH(CNode* pnode, vNodes)
                checkpoint.RelayTo(pnode);
        }
        return true;
    }
开发者ID:riftdotspace,项目名称:LAB,代码行数:37,代码来源:checkpoints.cpp


示例10: sizeof

DWORD CSage::Start()
{	
	USES_CONVERSION;
	
	//CEgRegKey key;	
	TCHAR pModName [1024] = { 0 };
	
    //detecting the module version
	::GetModuleFileName( NULL, pModName, sizeof(pModName) );
	
	CModuleVersion ver;
	ver.GetModuleVersionInfo(pModName);

	std::string sMsg("Fail to Setup user groups.");
	UserGroups clParams;
	m_nGroupsCount = GetCommandLineParams(clParams);
	if (m_SageConnector.SetGroups(clParams) == E_FAIL)
	{
		CTracer::TraceError(E_FAIL, sMsg.c_str());
		return E_FAIL;
	}

	
	TCHAR pVer[100] = { 0 };
	ver.GetValue(_T("ProductVersion"), pVer);

	CTracer::Trace(_T("------------------------------------"));
	CTracer::Trace(_T("FIX Interface Connector v.%s"), pVer );	
	CTracer::Trace(_T("Press Ctrl + C to stop the server..."));
	CTracer::Trace(_T("------------------------------------"));

	DWORD dwFlags;
	if(GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &dwFlags))
	{
		dwFlags &= ~(ENABLE_QUICK_EDIT | ENABLE_INSERT_MODE);
		SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), dwFlags);
	}

	m_hStopApplication = CreateEvent(NULL, TRUE, FALSE, _T("E53B916B-95BA-4e1f-917A-338580A74D91"));
	if (m_hStopApplication == NULL)
	{
		return CTracer::TraceError();
	}

	BOOL bRes = SetConsoleCtrlHandler(HandlerRoutine, TRUE);
	
	if (bRes == FALSE)
		return CTracer::TraceError();

	CTracer::Trace(_T("Starting Sage connector..."));

	DWORD dwRes = m_SageConnector.Start();
	
	if (dwRes)
	{
		CTracer::Trace(_T("Failed to start Sage connector."));
		return dwRes;
	}

	CTracer::Trace(_T("FIX Interface connector started."));
	CTracer::Trace(_T("Server started."));

	return 0;
}
开发者ID:AlexS2172,项目名称:IVRMstandard,代码行数:64,代码来源:SageImpl.cpp


示例11: sStr

wxWindow* wxWindow::CreateWindowFromHWND (
  wxWindow*                         pParent
, WXHWND                            hWnd
)
{
    wxString                        sStr(wxGetWindowClass(hWnd));
    long                            lId    = wxGetWindowId(hWnd);
    long                            lStyle = ::WinQueryWindowULong((HWND)hWnd
                                                                   ,QWL_STYLE
                                                                  );
    wxWindow*                       pWin = NULL;

    sStr.UpperCase();



    if (sStr == wxT("BUTTON"))
    {
        if (lStyle == BS_AUTOCHECKBOX)
        {
            pWin = new wxCheckBox;
        }
        else if (lStyle == BS_AUTORADIOBUTTON)
        {
            pWin = new wxRadioButton;
        }
        else if (lStyle & BS_BITMAP || lStyle == BS_USERBUTTON)
        {
            pWin = new wxBitmapButton;
        }
        else if (lStyle == BS_PUSHBUTTON)
        {
            pWin = new wxButton;
        }
        else if (lStyle == SS_GROUPBOX)
        {
            pWin = new wxStaticBox;
        }
        else
        {
            wxLogError(wxT("Don't know what kind of button this is: id = %ld"),
                       lId);
        }
    }
    else if (sStr == wxT("COMBOBOX"))
    {
        pWin = new wxComboBox;
    }
    else if (sStr == wxT("EDIT"))
    {
        pWin = new wxTextCtrl;
    }
    else if (sStr == wxT("LISTBOX"))
    {
        pWin = new wxListBox;
    }
    else if (sStr == wxT("SCROLLBAR"))
    {
        pWin = new wxScrollBar;
    }
    else if (sStr == wxT("MSCTLS_UPDOWN32"))
    {
        pWin = new wxSpinButton;
    }
    else if (sStr == wxT("MSCTLS_TRACKBAR32"))
    {
        pWin = new wxSlider;
    }
    else if (sStr == wxT("STATIC"))
    {
        if (lStyle == SS_TEXT)
            pWin = new wxStaticText;
        else if (lStyle == SS_ICON)
        {
            pWin = new wxStaticBitmap;
        }
    }
    else
    {
        wxString                    sMsg(wxT("Don't know how to convert from Windows class "));

        sMsg += sStr;
        wxLogError(sMsg);
    }
    if (pWin)
    {
        pParent->AddChild(pWin);
        pWin->SetEventHandler(pWin);
        pWin->SetHWND(hWnd);
        pWin->SetId(lId);
        pWin->SubclassWin(hWnd);
        pWin->AdoptAttributesFromHWND();
        pWin->SetupColours();
        return pWin;
    }
    else
        return NULL;
} // end of wxWindow::CreateWindowFromHWND
开发者ID:erwincoumans,项目名称:wxWidgets,代码行数:98,代码来源:nativdlg.cpp


示例12: NormalizeCharacterName

void AdviceManager::HandleAdviceResponse( Client *advisor, csString sAdvisee, csString message)
{
    if ( !advisor->GetAdvisor() )
    {
        psserver->SendSystemInfo(advisor->GetClientNum(),"You need to be an advisor to use this command.");
        return;
    }

    csString buf;
    // Source Client Name, Target Client Name, Message
    buf.Format("%s, %s, \"%s\"", advisor->GetName(), sAdvisee.GetData() , message.GetData());
    psserver->GetLogCSV()->Write(CSV_ADVICE, buf);

    // Find Advisee Client by name
    if (sAdvisee.Length())
    {
        sAdvisee = NormalizeCharacterName(sAdvisee);
    }
    Client *advisee = psserver->GetConnections()->Find(sAdvisee);
    if (!advisee)
    {
        // Create a new message to report TELL error and send
        // back to original person.
        csString sMsg("No player named ");
        sMsg += sAdvisee;
        sMsg += " is logged on to the system currently.";
        psserver->SendSystemError(advisor->GetClientNum(), sMsg);
        return;
    }

    // Can't allow you to advise yourself
    if ( advisee == advisor )
    {
        psserver->SendSystemError(advisor->GetClientNum(), "You are not allowed to advise yourself. Please wait for another advisor.");
        return;
    }

    // find existing Advicee in the List
    AdviceSession key;
    key.AdviseeClientNum = advisee->GetClientNum();
    AdviceSession *activeSession = AdviseeList.Get(advisee->GetClientNum(), NULL);

    if (!activeSession || (activeSession  && ( !activeSession->requestEvent ) && ( activeSession->GetAdvisor() == NULL ) ) )
    {
        psserver->SendSystemError(advisor->GetClientNum(), "%s has not requested help.", advisee->GetName());
        return;
    }

    if (activeSession  && ( activeSession->AdviseeClientNum != advisee->GetClientNum() ) )
    {
        Debug2( LOG_ANY, advisee->GetClientNum(), "Grabbed wrong advisor session: %d", activeSession->AdviseeClientNum );
    }

    if ( ( activeSession->GetAdvisor() != NULL ) && ( activeSession->AdvisorClientNum != advisor->GetClientNum() ) )
    {
        psserver->SendSystemError(advisor->GetClientNum(), "%s is being advised already, thank you.",  advisee->GetName());
        return;
    }

    if ( message.Length() == 0  && activeSession->status == SESSION_STATUS_UNKNOWN ) // advisor is claiming a session
    {
        // check to make sure advisor has only one claimed session.
        AdviceSession *loopSession;

        csHash< AdviceSession* >::GlobalIterator loop( AdviseeList.GetIterator() );

        while(loop.HasNext())
        {
        	loopSession = loop.Next();
            if (activeSession->status == SESSION_STATUS_CLAIMED && loopSession->GetAdvisor() == advisor )
            {
                psserver->SendSystemInfo(advisor->GetClientNum(), "You cannot have two messengers waiting for you at the same time, please answer %s's request first." , loopSession->adviseeName.GetData() );
                return;
            }
        }

        activeSession->SetAdvisor( advisor );
        psserver->SendSystemInfo(advisee->GetClientNum(), "An advisor is preparing an answer to your question, please be patient.");
        psserver->SendSystemInfo(advisor->GetClientNum(), "You have claimed the session with %s. Please provide an answer." , advisee->GetName() );

        for (size_t i = 0; i < advisors.GetSize(); i++)
        {
            if ( advisors[i].id != activeSession->AdvisorClientNum )
            {
                psserver->SendSystemInfo(advisors[i].id, "%s has proclaimed they know the answer to %s's question.", advisor->GetName(), advisee->GetName() );
            }
        }
        activeSession->status = SESSION_STATUS_CLAIMED;
    }
    else
    {
        if (message.IsEmpty())
        {
            psserver->SendSystemInfo(advisor->GetClientNum(), "Please enter the advice you wish to give.");
            return;
        }

        psChatMessage msgChat(activeSession->AdviseeClientNum, 0, advisor->GetName(), advisee->GetName(), message ,CHAT_ADVISOR,false);

        if ( activeSession->GetAdvisor() == NULL || activeSession->status != SESSION_STATUS_OWNED )
//.........这里部分代码省略.........
开发者ID:randomcoding,项目名称:PlaneShift-PSAI,代码行数:101,代码来源:advicemanager.cpp


示例13: ThreadSendAlert

void ThreadSendAlert()
{
    if (!mapArgs.count("-sendalert") && !mapArgs.count("-printalert"))
        return;

    MilliSleep(60*1000); // Wait a minute so we get connected

    //
    // Alerts are relayed around the network until nRelayUntil, flood
    // filling to every node.
    // After the relay time is past, new nodes are told about alerts
    // when they connect to peers, until either nExpiration or
    // the alert is cancelled by a newer alert.
    // Nodes never save alerts to disk, they are in-memory-only.
    //
    CAlert alert;
    alert.nRelayUntil   = GetTime() + 15 * 60;
    alert.nExpiration   = GetTime() + 365 * 60 * 60;
    alert.nID           = 1000;  // use https://github.com/zcash/zcash/wiki/specification#assigned-numbers to keep track of alert IDs
    alert.nCancel       = 0;   // cancels previous messages up to this ID number

    // These versions are protocol versions
    // 170002 : 1.0.0
    alert.nMinVer       = 170002;
    alert.nMaxVer       = 170002;

    //
    // main.cpp: 
    //  1000 for Misc warnings like out of disk space and clock is wrong
    //  2000 for longer invalid proof-of-work chain 
    //  Higher numbers mean higher priority
    //  4000 or higher will put the RPC into safe mode
    alert.nPriority     = 5000;
    alert.strComment    = "";
    alert.strStatusBar  = "URGENT: Upgrade required: see https://z.cash";
    alert.strRPCError   = "URGENT: Upgrade required: see https://z.cash";

    // Set specific client version/versions here. If setSubVer is empty, no filtering on subver is done:
    // alert.setSubVer.insert(std::string("/MagicBean:0.7.2/"));

    // Sign
    const CChainParams& chainparams = Params();
    std::string networkID = chainparams.NetworkIDString();
    bool fIsTestNet = networkID.compare("test") == 0;
    std::vector<unsigned char> vchTmp(ParseHex(fIsTestNet ? pszTestNetPrivKey : pszPrivKey));
    CPrivKey vchPrivKey(vchTmp.begin(), vchTmp.end());

    CDataStream sMsg(SER_NETWORK, CLIENT_VERSION);
    sMsg << *(CUnsignedAlert*)&alert;
    alert.vchMsg = std::vector<unsigned char>(sMsg.begin(), sMsg.end());
    CKey key;
    if (!key.SetPrivKey(vchPrivKey, false))
    {
        printf("ThreadSendAlert() : key.SetPrivKey failed\n");
        return;
    }
    if (!key.Sign(Hash(alert.vchMsg.begin(), alert.vchMsg.end()), alert.vchSig))
    {
        printf("ThreadSendAlert() : key.Sign failed\n");
        return;
    }

    // Test
    CDataStream sBuffer(SER_NETWORK, CLIENT_VERSION);
    sBuffer << alert;
    CAlert alert2;
    sBuffer >> alert2;
    if (!alert2.CheckSignature(chainparams.AlertKey()))
    {
        printf("ThreadSendAlert() : CheckSignature failed\n");
        return;
    }
    assert(alert2.vchMsg == alert.vchMsg);
    assert(alert2.vchSig == alert.vchSig);
    alert.SetNull();
    printf("\nThreadSendAlert:\n");
    printf("hash=%s\n", alert2.GetHash().ToString().c_str());
    printf("%s\n", alert2.ToString().c_str());
    printf("vchMsg=%s\n", HexStr(alert2.vchMsg).c_str());
    printf("vchSig=%s\n", HexStr(alert2.vchSig).c_str());

    // Confirm
    if (!mapArgs.count("-sendalert"))
        return;
    while (vNodes.size() < 1 && !ShutdownRequested())
        MilliSleep(500);
    if (ShutdownRequested())
        return;

    // Send
    printf("ThreadSendAlert() : Sending alert\n");
    int nSent = 0;
    {
        LOCK(cs_vNodes);
        BOOST_FOREACH(CNode* pnode, vNodes)
        {
            if (alert2.RelayTo(pnode))
            {
                printf("ThreadSendAlert() : Sent alert to %s\n", pnode->addr.ToString().c_str());
                nSent++;
//.........这里部分代码省略.........
开发者ID:aniemerg,项目名称:zcash,代码行数:101,代码来源:sendalert.cpp


示例14: LOG


//.........这里部分代码省略.........
            }

            // --------------------------------------------------------------
            // Allow a more REST like calling convention.  If the Method 
            // Name isn't found, search for one with the request method 
            // appended to the name ( "Get" or "Put" for POST)
            // --------------------------------------------------------------

            QString sMethodName  = pRequest->m_sMethod;
            bool    bMethodFound = false;

            if (m_Methods.contains(sMethodName))
                bMethodFound = true;
            else
            {
                switch( pRequest->m_eType )
                {
                    case RequestTypeHead:
                    case RequestTypeGet :
                        sMethodName = "Get" + sMethodName;
                        break;
                    case RequestTypePost:
                        sMethodName = "Put" + sMethodName;
                        break;
                    case RequestTypeUnknown:
                    case RequestTypeOptions:
                    case RequestTypeMSearch:
                    case RequestTypeSubscribe:
                    case RequestTypeUnsubscribe:
                    case RequestTypeNotify:
                    case RequestTypeResponse:
                        // silence compiler
                        break;
                }

                if (m_Methods.contains(sMethodName))
                    bMethodFound = true;
            }

            if (bMethodFound)
            {
                MethodInfo oInfo = m_Methods.value( sMethodName );

                if (( pRequest->m_eType & oInfo.m_eRequestType ) != 0)
                {
                    // ------------------------------------------------------
                    // Create new Instance of the Service Class so
                    // it's guaranteed to be on the same thread
                    // since we are making direct calls into it.
                    // ------------------------------------------------------

                    pService = 
                        qobject_cast<Service*>(m_oMetaObject.newInstance());

                    QVariant vResult = oInfo.Invoke(pService,
                                                    pRequest->m_mapParams);

                    bHandled = FormatResponse( pRequest, vResult );
                }
            }

            if (!bHandled)
                UPnp::FormatErrorResponse( pRequest, UPnPResult_InvalidAction );
        }
    }
    catch (HttpRedirectException &ex)
    {
        UPnp::FormatRedirectResponse( pRequest, ex.hostName );
        bHandled = true;
    }
    catch (HttpException &ex)
    {
        LOG(VB_GENERAL, LOG_ERR, ex.msg);
        UPnp::FormatErrorResponse( pRequest, UPnPResult_ActionFailed, ex.msg );

        bHandled = true;

    }
    catch (QString &sMsg)
    {
        LOG(VB_GENERAL, LOG_ERR, sMsg);
        UPnp::FormatErrorResponse( pRequest, UPnPResult_ActionFailed, sMsg );

        bHandled = true;
    }
    catch ( ...)
    {
        QString sMsg( "ServiceHost::ProcessRequest - Unexpected Exception" );

        LOG(VB_GENERAL, LOG_ERR, sMsg);
        UPnp::FormatErrorResponse( pRequest, UPnPResult_ActionFailed, sMsg );

        bHandled = true;
    }

    if (pService != nullptr)
        delete pService;

    return bHandled;
}
开发者ID:garybuhrmaster,项目名称:mythtv,代码行数:101,代码来源:servicehost.cpp


示例15: sMsg

void frmMain::readReply(QNetworkReply * replyIn)
{
    // Проверяем, не произошло ли ошибки при выполнении запроса:
    if (replyIn->error() != QNetworkReply::NoError)
    {
        // Ошибка произошла - сообщаем о ней. Если поднят флаг выхода -
        // предлагаем пользователю настроить параметры соединения. Если флаг
        // выхода не поднять - значит, пользовательский интерфейс уже открыт,
        // и смысла предлагать пользователю его открыть нет.
        QString sMsg(tr("Failed to get version info from site."));
        QString sErr(replyIn->errorString());
        if (bExitOnReply)
        {
            sMsg.append(tr(" Open connection settings?"));
            if (MsgUtilsMy::showQuestion(this, false, sMsg,
                QString(), sErr))
                bExitOnReply = false;
        }
        else
            MsgUtilsMy::showErrorMsg(this, sMsg, QString(), sErr);
        // Если установлен флаг выхода - выходим из программы, иначе показываем
        // основную форму:
        if (bExitOnReply)
            qApp->exit(0);
        else
            this->show();
        // Завершаем функцию:
        return;
    }
    // Получаем текст полученного ответа на запрос:
    QString sVer(replyIn->readAll());
    // Маркер начала версии программы:
    QString sVerStartMark(VERSION_START);
    // Маркер окончания версии программы:
    QString sVerEndMark(VERSION_END);
    // Проверка наличия версии программы в нужном формате.
    // Ищем маркер начала строки версии:
    int iVStart = sVer.indexOf(sVerStartMark, 0, Qt::CaseInsensitive);
    // Позиция маркера окончания строки версии:
    int iVEnd = -1;
    // В случае, если маркер начала версии найден - ищем маркер окончания версии:
    if (iVStart > -1)
        iVEnd = sVer.indexOf(sVerEndMark, iVStart, Qt::CaseInsensitive);
    // В случае, если маркер начала или маркер окончания строки версии не найден -
    // сообщаем об ошибке и завершаем функцию:
    if (iVStart == -1 || iVEnd == -1)
    {
        // Ошибка произошла - сообщаем о ней:
        MsgUtilsMy::showErrorMsg(this, tr("Error while readin version from site."),
            QString(), tr("Version start or version end marker is not found."));
        // Если установлен флаг выхода - выходим из программы, иначе показываем
        // основную форму:
        if (bExitOnReply)
            qApp->exit(0);
        else
            this->show();
        // Завершаем функцию:
        return;
    }
    // Убираем окончание строки, начиная с первого символа маркера окончания строки версии:
    sVer.remove(iVEnd, sVer.length() - iVEnd);
    // Убираем начало строки до версии, включая маркер начала версии:
    sVer.remove(0, iVStart + sVerStartMark.length());
    // Создаём объекты версий:
    LWVersion verCurrent(sCurVer);
    LWVersion verSite(sVer);
    // Если версия на сайте больше - сообщаем об этом и предлагаем перейти на сайт:
    if (verSite.isHigherThan(verCurrent))
    {
        if (MsgUtilsMy::showQuestion(this, false,
            tr("New %1 version is available. Open download page?").arg(sProg)))
            QDesktopServices::openUrl(QUrl(sPageGoTo));
    }
    // Установлена последняя версия. В случае, если поднят флаг выхода
    // после проверки - сообщать о наличии последней версии пользователю
    // не нужно. В случае, если флаг выхода не поднят - значит, проверка
    // запущена пользователем, и надо сообщить ему, что у него самая
    // последняя версия:
    else
    {
        // Сообщаем об отстутствии обновлений в случае, если вывод
        // таких сообщений явно включен, и в случае, если вывод
        // не выключен и не поднят флаг выхода после проверки:
        if ((iNupMsg == 2) || ((iNupMsg != 1) && !bExitOnReply))
            // Сообщаем, что установлена последняя версия:
            MsgUtilsMy::showInfoMsg(this,
                tr("Latest %1 version is installed.").arg(sProg));
    }
    // Если поднят флаг завершения работы приложения после получения ответа -
    // завершаем работу приложения, иначе показываем главное окно:
    if (bExitOnReply)
        qApp->exit(0);
    else
        this->show();
}
开发者ID:sapfir63,项目名称:door_sensor_1.0_qrserialport,代码行数:95,代码来源:frmmain.cpp



注:本文中的sMsg函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sName函数代码示例发布时间:2022-05-30
下一篇:
C++ sLock函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap