void Server::doPeerMsg(shared_ptr<IMChat::MsgData> ptrMsg, const string& serializaStr) { m_mutex.lock(); //网络连接; SessionPtr ptrConnection = m_tcpserver.getConnection_Manager().findUser(ptrMsg->toid()); if (NULL != ptrConnection) { //如果用户在当前服务器直接发送; m_codec.Send(ptrConnection, *ptrMsg); } else { string serverSocket = m_redis.Get("online:" + ptrMsg->toid()); //如果用户在其他服务器Publish消息; if (!serverSocket.empty()) { string keyServer("peerMsg:"); keyServer += serverSocket; m_redis.Publish(keyServer, serializaStr); } else { //如果用户未登陆;将消息插入到未读消息列表; //未读消息长度; int nListLen = 0; auto ptrContext = m_redis.GetContext(); redisReply* ptrReply = NULL; string keyUnreadList("unreadMsg:"); keyUnreadList += ptrMsg->toid(); //从左边入列表; ptrReply = static_cast<redisReply*>(redisCommand(ptrContext, "LPUSH %s %b", keyUnreadList.c_str(), serializaStr.c_str(), serializaStr.size())); if (NULL != ptrReply && REDIS_REPLY_INTEGER == ptrReply->type) { nListLen = ptrReply->integer; } freeReplyObject(ptrReply); //只保存99条消息;如果超过截取后面99条; if (nListLen > 99) { ptrReply = static_cast<redisReply*>(redisCommand(ptrContext, "LTRIM %s %d %d", keyUnreadList.c_str(), 0, 99)); freeReplyObject(ptrReply); } } } m_mutex.unlock(); }
wxString wxFileTypeImpl::GetCommand(const wxString& verb) const { // suppress possible error messages wxLogNull nolog; wxString strKey; { wxRegKey explorerKey(wxRegKey::HKCU, wxT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\") + m_ext); if (explorerKey.Exists()) { if (explorerKey.Open(wxRegKey::Read)) { if (explorerKey.QueryValue(wxT("Progid"), strKey)) { strKey = wxFileTypeImplGetCurVer(strKey); } } } } if (!strKey && wxRegKey(wxRegKey::HKCR, m_ext + wxT("\\shell")).Exists()) strKey = m_ext; if ( !strKey && !m_strFileType.empty()) { wxString fileType = wxFileTypeImplGetCurVer(m_strFileType); if (wxRegKey(wxRegKey::HKCR, fileType + wxT("\\shell")).Exists()) strKey = fileType; } if ( !strKey ) { // no info return wxEmptyString; } strKey << wxT("\\shell\\") << verb; wxRegKey key(wxRegKey::HKCR, strKey + wxT("\\command")); wxString command; if ( key.Open(wxRegKey::Read) ) { // it's the default value of the key if ( key.QueryValue(wxEmptyString, command) ) { bool foundFilename = CanonicalizeParams(command); #if wxUSE_IPC // look whether we must issue some DDE requests to the application // (and not just launch it) strKey += wxT("\\DDEExec"); wxRegKey keyDDE(wxRegKey::HKCR, strKey); if ( keyDDE.Open(wxRegKey::Read) ) { wxString ddeCommand, ddeServer, ddeTopic; keyDDE.QueryValue(wxEmptyString, ddeCommand); ddeCommand.Replace(wxT("%1"), wxT("%s")); wxRegKey keyServer(wxRegKey::HKCR, strKey + wxT("\\Application")); keyServer.QueryValue(wxEmptyString, ddeServer); wxRegKey keyTopic(wxRegKey::HKCR, strKey + wxT("\\Topic")); keyTopic.QueryValue(wxEmptyString, ddeTopic); if (ddeTopic.empty()) ddeTopic = wxT("System"); // HACK: we use a special feature of wxExecute which exists // just because we need it here: it will establish DDE // conversation with the program it just launched command.Prepend(wxT("WX_DDE#")); command << wxT('#') << ddeServer << wxT('#') << ddeTopic << wxT('#') << ddeCommand; } else #endif // wxUSE_IPC if ( !foundFilename ) { // we didn't find any '%1' - the application doesn't know which // file to open (note that we only do it if there is no DDEExec // subkey) // // HACK: append the filename at the end, hope that it will do command << wxT(" %s"); } } } //else: no such file type or no value, will return empty string return command; }
wxString wxFileTypeImpl::GetCommand(const wxString& verb) const { // suppress possible error messages wxLogNull nolog; wxString strKey; // Since Windows Vista the association used by Explorer is different from // the association information stored in the traditional part of the // registry. Unfortunately the new schema doesn't seem to be documented // anywhere so using it involves a bit of guesswork: // // The information is stored under Explorer-specific key whose path is // below. The interesting part is UserChoice subkey which is the only one // we use so far but there is also OpenWithProgids subkey which can exist // even if UserChoice doesn't. However in practice there doesn't seem to be // any cases when OpenWithProgids values for the given extension are // different from those found directly under HKCR\.ext, so for now we don't // bother to use this, apparently the programs registering their file type // associations do it in both places. We do use UserChoice because when the // association is manually changed by the user it's only recorded there and // so must override whatever value was created under HKCR by the setup // program. { wxRegKey explorerKey ( wxRegKey::HKCU, wxT("Software\\Microsoft\\Windows\\CurrentVersion\\") wxT("Explorer\\FileExts\\") + m_ext + wxT("\\UserChoice") ); if ( explorerKey.Open(wxRegKey::Read) && explorerKey.QueryValue(wxT("Progid"), strKey) ) { strKey = wxFileTypeImplGetCurVer(strKey); } } if (!strKey && wxRegKey(wxRegKey::HKCR, m_ext + wxT("\\shell")).Exists()) strKey = m_ext; if ( !strKey && !m_strFileType.empty()) { wxString fileType = wxFileTypeImplGetCurVer(m_strFileType); if (wxRegKey(wxRegKey::HKCR, fileType + wxT("\\shell")).Exists()) strKey = fileType; } if ( !strKey ) { // no info return wxEmptyString; } strKey << wxT("\\shell\\") << verb; wxRegKey key(wxRegKey::HKCR, strKey + wxT("\\command")); wxString command; if ( key.Open(wxRegKey::Read) ) { // it's the default value of the key if ( key.QueryValue(wxEmptyString, command) ) { bool foundFilename = CanonicalizeParams(command); #if wxUSE_IPC // look whether we must issue some DDE requests to the application // (and not just launch it) strKey += wxT("\\DDEExec"); wxRegKey keyDDE(wxRegKey::HKCR, strKey); if ( keyDDE.Open(wxRegKey::Read) ) { wxString ddeCommand, ddeServer, ddeTopic; keyDDE.QueryValue(wxEmptyString, ddeCommand); // in some cases "DDEExec" subkey exists but has no value, we // shouldn't use DDE in this case if ( !ddeCommand.empty() ) { ddeCommand.Replace(wxT("%1"), wxT("%s")); wxRegKey keyServer(wxRegKey::HKCR, strKey + wxT("\\Application")); keyServer.QueryValue(wxEmptyString, ddeServer); wxRegKey keyTopic(wxRegKey::HKCR, strKey + wxT("\\Topic")); keyTopic.QueryValue(wxEmptyString, ddeTopic); if (ddeTopic.empty()) ddeTopic = wxT("System"); // HACK: we use a special feature of wxExecute which exists // just because we need it here: it will establish DDE // conversation with the program it just launched command.Prepend(wxT("WX_DDE#")); command << wxT('#') << ddeServer << wxT('#') << ddeTopic << wxT('#') << ddeCommand; } } else #endif // wxUSE_IPC if ( !foundFilename ) { // we didn't find any '%1' - the application doesn't know which // file to open (note that we only do it if there is no DDEExec // subkey) // // HACK: append the filename at the end, hope that it will do command << wxT(" %s"); } } } //else: no such file type or no value, will return empty string return command; }