int YAddingSong::ShowDetail(CFileMgr::filesArrayT files) { int iSearched = 0; for (CFileMgr::filesArrayIterT iter=files.begin();iter!=files.end();++iter) { TStreamFormat tf = thePlayCenter->GetFileFormat(*iter); if (tf==TStreamFormat::sfUnknown) { sLogWarn("歌曲<%s>格式暂不支持",iter->GetBuffer()); iter->ReleaseBuffer(); } else { iSearched++; spSongInfoT spSongInfo; theDbMgr->GetUserDB()->AddSongToPlayList(*iter,(unsigned int)(_pSongList->GetTag()),spSongInfo); thePlayCenter->AddSongToList(*spSongInfo,(unsigned int)(_pSongList->GetTag())); YSongListItemUI* songItem = new YSongListItemUI; ASSERT(songItem); songItem->SetSong(spSongInfo); _pSongList->Add(songItem); _pText->SetText(_T("正在导入:")+spSongInfo->GetLocalPath()); } } return iSearched; }
bool CDynamicPlugins::_LoadPlugin( const std::string& plugin_name, CDynamicLib::Ptr lib_ptr ) { sLogWarn("[component:warn] CComponentPlugins::loadPlugin begin"); if( !lib_ptr || !lib_ptr->Load() ) { return false; } // 同时要有以上三种接口的dll才是标准插件,否则不承认; DLL_START_PLUGIN pFunc = (DLL_START_PLUGIN)lib_ptr->GetSymbol("DllPlugin"); if ( !pFunc ) { sLogWarn("[component:warn] CComponentPlugins::loadPlugin cant find entry(DllPlugin)"); return false; } sLogInfo("[component:info ] CComponentPlugins::loadPlugin load dll(%s)'s plugins", plugin_name.c_str()); (*pFunc)(lib_ptr); sLogInfo("[component:info ] CComponentPlugins::loadPlugin load dll(%s)'s plugins finished", plugin_name.c_str()); return true; }
void CComFactoryManager::AddFactory(const ComID& component_id, const detail::CComFactory::Ptr& factory) { sLogInfo("[component:info ] CComponentRepository::loadPlugin load component(%s)", component_id.c_str()); pthread_mutex_lock(&mutex_factory_list_); FactoryMap::iterator itor = component_factory_list_.find(component_id); if (itor != component_factory_list_.end()) { sLogWarn("[component:warn ] CComponentRepository::~loadPlugin component(%s) existed,replace it", component_id.c_str()); component_factory_list_.erase(itor); }; FactoryInfoPtr temp_factory(new FactoryInfo); temp_factory->component_factory = factory; component_factory_list_.insert(make_pair(component_id, temp_factory)); pthread_mutex_unlock(&mutex_factory_list_); sLogInfo("[component:warn ] CComponentRepository::loadPlugin component(%s) finished", component_id.c_str()); }
void CComFactoryManager::AddFactory(const ComID& component_id, const detail::CComFactory::Ptr& factory, CDynamicLib::Ptr& dynamic_lib_ptr) { sLogInfo("[component:info ] CComponentRepository::loadPlugin load component(%s)", component_id.c_str()); pthread_mutex_lock(&mutex_factory_list_); FactoryMap::iterator itor = component_factory_list_.find(component_id); if (itor != component_factory_list_.end()) { sLogWarn("[component:warn ] CComponentRepository::~loadPlugin component(%s) existed,replace it", component_id.c_str()); component_factory_list_.erase(itor); } /* * 把插件的引用给工厂一份,只要工厂不释放插件就不会释放; */ FactoryInfoPtr temp_factory(new FactoryInfo); temp_factory->component_factory = factory; temp_factory->denpend_dyn_lib = dynamic_lib_ptr; component_factory_list_.insert(make_pair(component_id, temp_factory)); pthread_mutex_unlock(&mutex_factory_list_); sLogInfo("[component:warn ] CComponentRepository::loadPlugin component(%s) finished", component_id.c_str()); }
/* void CLoginWindow::OnWebService(void *pRequest ,void *pProto) { url::CRequest *theRequest = (url::CRequest *)pRequest; LogonUserInfoT * theUser = static_cast<LogonUserInfoT*>(pProto); if(url::WSRT_LOGIN != theRequest->GetRequestType() && url::WSRT_WEBLOGIN != theRequest->GetRequestType()) return; CControlUI *pCtl = GetPaintMgr()->FindControl(_T("login")); CButtonUI *pLoginBtn = static_cast<CButtonUI*>(pCtl); if(theRequest->IsTimeOut()) { if(pLoginBtn) CInfoWindow::ShowInfoWindow(this->m_hWnd,pLoginBtn->GetPos(),_T("µÇ¼³¬Ê±£¬ÇëÖØÊÔ¡£")); EnableWindow(TRUE); return; } spLogonUserInfoT spLogonUserInfo(new LogonUserInfoT(*theUser)); if (!spLogonUserInfo) { if(pLoginBtn) CInfoWindow::ShowInfoWindow(this->m_hWnd,pLoginBtn->GetPos(),_T(" µÇ¼ʧ°Ü£¬Óû§Ãû»òÃÜÂë´íÎó! ")); EnableWindow(TRUE); return ; } { if(url::WSRT_WEBLOGIN != theRequest->GetRequestType()) { spLogonUserInfo->sLogonEmail = m_sUserName; spLogonUserInfo->sPasswordMD5 = m_sPasswordMd5; //spLogonUserInfo->bKeepLogged = !!m_isKeepLogin; }else { assert(!spLogonUserInfo->sLogonEmail.IsEmpty()); assert(!spLogonUserInfo->sPasswordMD5.IsEmpty()); //spLogonUserInfo->bKeepLogged = true; } CControlUI *pCheckBox = GetPaintMgr()->FindControl(_T("KeepLogin")); CCheckBoxUI *pKeepLogin = static_cast<CCheckBoxUI*>(pCheckBox); bool autoLogin = pKeepLogin->GetCheck(); // if (url::WSRT_WEBLOGIN == pRequest->GetRequestType()) // autoLogin = true; theConfigMgr->GetNormalConfig()->EnableAutoLogin(autoLogin); theConfigMgr->GetNormalConfig()->Save(); if(theDbMgr->GetGlobalDBase()->GetUserInfo(mci::unicode_2_utf8(spLogonUserInfo->sUserID).c_str())) theDbMgr->GetGlobalDBase()->UpdateUserInfo(spLogonUserInfo); else theDbMgr->GetGlobalDBase()->AddUserInfo(spLogonUserInfo); theRuntimeState->SetUserInfo(spLogonUserInfo); RECT rtWin; ::GetWindowRect(theMainWin->GetHWND(),&rtWin); POINT rtPos = {rtWin.left+25,rtWin.top+35}; ::ScreenToClient(theMainWin->GetHWND(),&rtPos); CInfoWindow::ShowInfoWindow(theMainWin->GetHWND(),rtPos,_T(" µÇ¼³É¹¦ ")); Close(IDOK); } // CurlData* pdata = (CurlData*)pRequest; // int* nRet = (int*)pProto; } */ void CLoginWindow::OnWebService(void *pRequest ,void *pProto) { CControlUI *pCtl = GetPaintMgr()->FindControl(_T("login")); CButtonUI *pLoginBtn = static_cast<CButtonUI*>(pCtl); CurlData* pdata = (CurlData*)pRequest; int* nRet = (int*)pProto; if (!pdata) { CInfoWindow::ShowInfoWindow(this->m_hWnd,pLoginBtn->GetPos(),_T(" µÇ¼ʧ°Ü£¬´íÎóÀàÐÍ[δ֪]! ")); EnableWindow(TRUE); return; } if(url::WSRT_LOGIN != pdata->n_type && url::WSRT_WEBLOGIN != pdata->n_type) { CInfoWindow::ShowInfoWindow(this->m_hWnd,pLoginBtn->GetPos(),_T(" µÇ¼ʧ°Ü£¬´íÎóÀàÐÍ[·ÇWSRT_LOGIN]! ")); EnableWindow(TRUE); return; } static CResponseParser2 Parser; std::string xmlbuf; xmlbuf.assign(pdata->buffer); // assert(!xmlbuf.empty()); std::string bufLog = mci::utf8_2_ansi(xmlbuf.c_str()); sLogWarn(bufLog.c_str()); //modify by dfn.li 2014-01-17 if(bufLog[0] == '?') { bufLog = bufLog.substr(1); } xmlbuf = mci::ansi_2_utf8(bufLog.c_str()); int t_begin = clock(); void *pResponse = NULL; pResponse = Parser.Parse(pdata->n_type,xmlbuf); int t_time = clock() - t_begin; LogonUserInfoT * theUser = static_cast<LogonUserInfoT*>(pResponse); if (!theUser) { if(pLoginBtn) CInfoWindow::ShowInfoWindow(this->m_hWnd,pLoginBtn->GetPos(),_T(" µÇ¼ʧ°Ü£¬Óû§Ãû»òÃÜÂë´íÎó! ")); EnableWindow(TRUE); return ; } // if(theRequest->IsTimeOut()) // { // if(pLoginBtn) // CInfoWindow::ShowInfoWindow(this->m_hWnd,pLoginBtn->GetPos(),_T("µÇ¼³¬Ê±£¬ÇëÖØÊÔ¡£")); // EnableWindow(TRUE); // return; // } spLogonUserInfoT spLogonUserInfo(new LogonUserInfoT(*theUser)); if (!spLogonUserInfo) { if(pLoginBtn) CInfoWindow::ShowInfoWindow(this->m_hWnd,pLoginBtn->GetPos(),_T(" µÇ¼ʧ°Ü£¬Óû§Ãû»òÃÜÂë´íÎó! ")); EnableWindow(TRUE); return ; } { if(url::WSRT_WEBLOGIN != pdata->n_type) { spLogonUserInfo->sLogonEmail = m_sUserName; spLogonUserInfo->sPasswordMD5 = m_sPasswordMd5; //spLogonUserInfo->bKeepLogged = !!m_isKeepLogin; }else { assert(!spLogonUserInfo->sLogonEmail.IsEmpty()); assert(!spLogonUserInfo->sPasswordMD5.IsEmpty()); //spLogonUserInfo->bKeepLogged = true; } CControlUI *pCheckBox = GetPaintMgr()->FindControl(_T("KeepLogin")); CCheckBoxUI *pKeepLogin = static_cast<CCheckBoxUI*>(pCheckBox); bool autoLogin = pKeepLogin->GetCheck(); // if (url::WSRT_WEBLOGIN == pRequest->GetRequestType()) // autoLogin = true; theConfigMgr->GetNormalConfig()->EnableAutoLogin(autoLogin); theConfigMgr->GetNormalConfig()->Save(); if(theDbMgr->GetGlobalDBase()->GetUserInfo(mci::unicode_2_utf8(spLogonUserInfo->sUserID).c_str())) theDbMgr->GetGlobalDBase()->UpdateUserInfo(spLogonUserInfo); else theDbMgr->GetGlobalDBase()->AddUserInfo(spLogonUserInfo); theRuntimeState->SetUserInfo(spLogonUserInfo); RECT rtWin; ::GetWindowRect(theMainWin->GetHWND(),&rtWin); POINT rtPos = {rtWin.left+25,rtWin.top+35}; ::ScreenToClient(theMainWin->GetHWND(),&rtPos); CInfoWindow::ShowInfoWindow(theMainWin->GetHWND(),rtPos,_T(" µÇ¼³É¹¦ ")); EnableWindow(TRUE); Close(IDOK); } }