int LuaV6Chat3App::AddServer(lua_State *luaState) { V6Chat3App *App = GetV6Chat3App(luaState); if (App) { size_t name_len=lua_objlen(luaState, 2); const char *name = lua_tolstring(luaState, 2, &name_len); size_t admain_len=lua_objlen(luaState, 3); const char *admain = lua_tolstring(luaState, 3, &admain_len); size_t account_len=lua_objlen(luaState, 4); const char *account = lua_tolstring(luaState, 4, &account_len); size_t password_len=lua_objlen(luaState, 5); const char *password = lua_tolstring(luaState, 5, &password_len); size_t introduction_len=lua_objlen(luaState, 6); const char *introduction = lua_tolstring(luaState, 6, &introduction_len); Handle<ServerInfo> server(new ServerInfo( 0, V6Util::Utf8ToUnicode(name).c_str(), admain, DEFAULT_XMPP_PORT, V6Util::Utf8ToUnicode(introduction).c_str(), account, password )); ServerList *list = ServerList::Instance(); list->AddServer(server); } return 0; }
void ServerMsgSender::UpdateProfileMsg() { ServerList *sList = ServerList::Instance(); Handle<ServerInfo> server; if(sList->GetServer(serverid, server)) { server->AskUserInfo(serveruid); } }
int LuaV6Chat3App::StartServer(lua_State *luaState) { V6Chat3App *App = GetV6Chat3App(luaState); if (App) { ServerList *sList = ServerList::Instance(); sList->Connect(); } return 0; }
void ServerMsgSender::AddUserAskMsg() { ServerList *sList = ServerList::Instance(); Handle<ServerInfo> server; if(sList->GetServer(serverid, server)) { server->AddUser(serveruid); } }
ServerSettings ServerGroupSettings::serverByIndex(int index) const { ServerList servers = serverList(); if(index < servers.count()) { return servers[index]; } return ServerSettings(); }
void ServerMsgSender::ReplyAddUserMsg(bool agree) { if(agree) { ServerList *sList = ServerList::Instance(); Handle<ServerInfo> server; if(sList->GetServer(serverid, server)) { server->AddUser(serveruid); } } }
ServerList ServerRepository::select(const string& where) { soci::rowset<row> rs = dataBase.prepare << "SELECT server.server_id as Server_server_id, server.sys_userid as Server_sys_userid, server.sys_groupid as Server_sys_groupid, server.sys_perm_user as Server_sys_perm_user, server.sys_perm_group as Server_sys_perm_group, server.sys_perm_other as Server_sys_perm_other, server.server_name as Server_server_name, server.mail_server as Server_mail_server, server.web_server as Server_web_server, server.dns_server as Server_dns_server, server.file_server as Server_file_server, server.db_server as Server_db_server, server.vserver_server as Server_vserver_server, server.proxy_server as Server_proxy_server, server.firewall_server as Server_firewall_server, server.config as Server_config, server.updated as Server_updated, server.mirror_server_id as Server_mirror_server_id, server.dbversion as Server_dbversion, server.active as Server_active " " FROM server" << (where.size()?" WHERE "+where:""); ServerList serverList; for(row& r: rs) { ServerPtr server(new Server); type_conversion<Server>::from_base(r, i_ok, *server); serverList.push_back(server); } return serverList; }
int LuaV6Chat3App::GetSearchFriendResult(lua_State *luaState) { V6Chat3App *App = GetV6Chat3App(luaState); if (App) { int id = lua_tointeger(luaState, 2); ServerList *list = ServerList::Instance(); Handle<ServerInfo> server; if(list->GetServer(id, server)) { std::list<VCardInfo> vCardList; server->GetSearchUsersResult(vCardList); lua_newtable(luaState); // 创建一个表格,放在栈顶 int i=1; for(std::list<VCardInfo>::const_iterator iter=vCardList.begin(); iter!=vCardList.end(); ++iter, ++i) { lua_pushnumber(luaState, i); lua_newtable(luaState); // 压入value,也是一个table(subtable) lua_pushstring(luaState, "id"); lua_pushnumber(luaState, iter->uid); lua_settable(luaState,-3); // 弹出key,value,并设置到subtable里面去 lua_pushstring(luaState, "account"); lua_pushstring(luaState, iter->account.c_str()); lua_settable(luaState,-3); // 弹出key,value,并设置到subtable里面去 lua_pushstring(luaState, "formatted_name"); lua_pushstring(luaState, iter->formattedName.c_str()); lua_settable(luaState,-3); // 弹出key,value,并设置到subtable里面去 wstring headImagePath(USERHEAD_RELATIVE_PATH); headImagePath = headImagePath + L"\\" + iter->photoRelativePath; XL_BITMAP_HANDLE bmp = V6Util::GetUserDataImageHandle(headImagePath.c_str()); if(bmp) { lua_pushstring(luaState, "head"); if(!XLUE_PushBitmap(luaState, bmp)) lua_pushnil(luaState); lua_settable(luaState,-3); //弹出key,value,并设置到subtable里面去 } lua_settable(luaState,-3); // 这时候父table的位置还是-3,弹出key,value(subtable),并设置到table里去 } return 1; } } lua_pushnil(luaState); return 1; }
bool ServerUserInfo::Delete() { std::stringstream sid; sid << uid; ServerList *sList = ServerList::Instance(); Handle<ServerInfo> server; if(sList->GetServer(serverid, server)) { server->DeleteUser(serveruid); return delete_peerProfile(sid.str().c_str()); } return false; }
int LuaV6Chat3App::ChangeServerInfo(lua_State *luaState) { V6Chat3App *App = GetV6Chat3App(luaState); if (App) { int id = lua_tointeger(luaState, 2); ServerList *list = ServerList::Instance(); Handle<ServerInfo> server; if(list->GetServer(id, server)) { size_t name_len=lua_objlen(luaState, 3); const char *name = lua_tolstring(luaState, 3, &name_len); size_t admain_len=lua_objlen(luaState, 4); const char *admain = lua_tolstring(luaState, 4, &admain_len); size_t account_len=lua_objlen(luaState, 5); const char *account = lua_tolstring(luaState, 5, &account_len); size_t password_len=lua_objlen(luaState, 6); const char *password = lua_tolstring(luaState, 6, &password_len); size_t introduction_len=lua_objlen(luaState, 7); const char *introduction = lua_tolstring(luaState, 7, &introduction_len); if(name) server->SetName(V6Util::Utf8ToUnicode(name)); if(admain) server->SetIp(admain); if(account) server->SetUid(account); if(password) server->SetUpassword(password); if(introduction) server->SetDescription(V6Util::Utf8ToUnicode(introduction)); if(server->HasChange()) { server->DisConnect(); server->Connect(); } } } return 0; }
void ServerUserInfo::GetLocation(std::wstring &location) { if(user_offline == state) { location = L"ÀëÏß"; return; } else { ServerList *sList = ServerList::Instance(); Handle<ServerInfo> server; if(sList->GetServer(serverid, server)) { location = server->GetName(); } else location = L"δ֪À´Ô´"; } }
void ServerMsgSender::ChatWithTextMsg(const std::wstring &text, const std::string &sendTime) { ServerList *sList = ServerList::Instance(); Handle<ServerInfo> server; if(sList->GetServer(serverid, server)) { string mtext = V6Util::UnicodeToAnsi(text.c_str()); map<int, string> nis; tr1::regex rxFloat("<\\d+>"); tr1::sregex_token_iterator ite(mtext.begin(), mtext.end(), rxFloat), end; SendFileList *list = SendFileList::Instance(); // 检查内容中是否含有文件 for ( ; ite != end; ++ite) { string w = ite->str(); string wi = w.substr(1, w.length()-2); int ni = atoi(wi.c_str()); nis.insert(make_pair(ni, wi)); } for(map<int, string>::iterator it = nis.begin(); it != nis.end(); ++it) { wstring filepath; string rsid; if(list->GetFilePath(it->first, filepath)) { if(server->SendFile(serveruid, filepath, rsid)) { tr1::regex rxFloat(it->second); mtext = tr1::regex_replace(mtext, rxFloat, rsid); } } } server->SendText(serveruid, V6Util::AnsiToUtf8(mtext.c_str())); } }
int LuaV6Chat3App::SearchFriendOnServer(lua_State *luaState) { V6Chat3App *App = GetV6Chat3App(luaState); if (App) { int id = lua_tointeger(luaState, 2); ServerList *list = ServerList::Instance(); Handle<ServerInfo> server; if(list->GetServer(id, server)) { server->ClearSearchUsersResult(); size_t search_content_len=lua_objlen(luaState, 3); const char *search_content = lua_tolstring(luaState, 3, &search_content_len); server->AskUserInfo(search_content); } } return 0; }
int LuaV6Chat3App::GetServerInfoByID(lua_State *luaState) { V6Chat3App *App = GetV6Chat3App(luaState); if (App) { int id = lua_tointeger(luaState, 2); ServerList *list = ServerList::Instance(); Handle<ServerInfo> server; if(list->GetServer(id, server)) { lua_newtable(luaState); lua_pushstring(luaState, "id"); lua_pushnumber(luaState, server->GetId()); lua_settable(luaState,-3); // 弹出key,value,并设置到subtable里面去 lua_pushstring(luaState, "server_name"); lua_pushstring(luaState, V6Util::UnicodeToUtf8(server->GetName().c_str()).c_str()); lua_settable(luaState,-3); // 弹出key,value,并设置到subtable里面去 lua_pushstring(luaState, "account"); lua_pushstring(luaState, server->GetUid().c_str()); lua_settable(luaState,-3); // 弹出key,value,并设置到subtable里面去 lua_pushstring(luaState, "password"); lua_pushstring(luaState, server->GetUpassword().c_str()); lua_settable(luaState,-3); // 弹出key,value,并设置到subtable里面去 lua_pushstring(luaState, "introduction"); lua_pushstring(luaState, V6Util::UnicodeToUtf8(server->GetDescription().c_str()).c_str()); lua_settable(luaState,-3); // 弹出key,value,并设置到subtable里面去 lua_pushstring(luaState, "domain"); lua_pushstring(luaState, server->GetIp().c_str()); lua_settable(luaState,-3); // 弹出key,value,并设置到subtable里面去 lua_pushstring(luaState, "state"); lua_pushnumber(luaState, server->GetState()); lua_settable(luaState,-3); // 弹出key,value,并设置到subtable里面去 return 1; } } lua_pushnil(luaState); return 1; }
int LuaV6Chat3App::GetServerList(lua_State *luaState) { V6Chat3App *App = GetV6Chat3App(luaState); if (App) { ServerList *list = ServerList::Instance(); lua_newtable(luaState); // 创建一个表格,放在栈顶 int i=1; std::map<unsigned int, Handle<ServerInfo>>& servers = list->GetServers(); for(ServerList::ServerIter iter=servers.begin(); iter!=servers.end(); ++iter, ++i) { lua_pushnumber(luaState, i); lua_newtable(luaState); // 压入value,也是一个table(subtable) lua_pushstring(luaState, "id"); lua_pushnumber(luaState, iter->second->GetId()); lua_settable(luaState,-3); // 弹出key,value,并设置到subtable里面去 lua_pushstring(luaState, "server_name"); lua_pushstring(luaState, V6Util::UnicodeToUtf8(iter->second->GetName().c_str()).c_str()); lua_settable(luaState,-3); // 弹出key,value,并设置到subtable里面去 lua_pushstring(luaState, "introduction"); lua_pushstring(luaState, V6Util::UnicodeToUtf8(iter->second->GetDescription().c_str()).c_str()); lua_settable(luaState,-3); // 弹出key,value,并设置到subtable里面去 lua_pushstring(luaState, "domain"); lua_pushstring(luaState, iter->second->GetIp().c_str()); lua_settable(luaState,-3); // 弹出key,value,并设置到subtable里面去 lua_pushstring(luaState, "state"); lua_pushnumber(luaState, iter->second->GetState()); lua_settable(luaState,-3); // 弹出key,value,并设置到subtable里面去 lua_settable(luaState,-3); // 这时候父table的位置还是-3,弹出key,value(subtable),并设置到table里去 } return 1; } lua_pushnil(luaState); return 1; }
/*! * \fn int main(int argc, char **argv) * Fonction principale * \return Le code de fin d'execution de la main loop. */ int main (int argc,char **argv) { QApplication app(argc,argv); MainWindow *fen = new MainWindow(NULL); IIrcEngine *engine = NonNativeIrcEngine::engine(); QObject::connect(fen, SIGNAL(connectMe(const QString&, int, const QString&)), engine, SLOT(initiateConnection(const QString&, int, const QString&))); QObject::connect(engine, SIGNAL(lineReceived(QString)), fen, SLOT(readServer(QString))); QObject::connect(fen, SIGNAL(sendASCIIMessage(const QString&)), engine, SLOT(sendASCIIMessage(const QString&))); /* La QMainWindow */ MainWindowView *mW = new MainWindowView(fen,NULL); mW->show(); XmlConfManager *confMan = XmlConfManager::confManager(); /*confMan->addServer("test"); confMan->addNetwork("test", confMan->createNetwork("irc.fansub-irc.eu", "6667")); confMan->changeUser("test", confMan->createUser("pierre", "pierreghost", "user", "real")); confMan->changeFavChan("test", "#fsf,#Kyubi-Wolf"); confMan->changeCommand("test", "/ns identify albachat"); confMan->save();*/ confMan->read(); ServerList *serverList = new ServerList(); QObject::connect(serverList, SIGNAL(connectSignal(QString&, int, QString&)), fen, SLOT(connexion(QString&, int, QString&))); QObject::connect(engine, SIGNAL(connectError()), serverList, SLOT(reconnect())); serverList->show(); return app.exec(); }
void SpanningTreeProtocolInterface::GetServerList(ServerList& sl) { for (server_hash::iterator i = Utils->serverlist.begin(); i != Utils->serverlist.end(); i++) { ServerInfo ps; ps.servername = i->second->GetName(); TreeServer* s = i->second->GetParent(); ps.parentname = s ? s->GetName() : ""; ps.usercount = i->second->UserCount; ps.opercount = i->second->OperCount; ps.gecos = i->second->GetDesc(); ps.latencyms = i->second->rtt; sl.push_back(ps); } }
//连接网关服务器成功后,服务器自动推送消息,返回网关服务器列表 bool LoginLayerUC::ProcessMsg(int type, google::protobuf::Message *msg) { m_iCurrentType = type; switch (type) { case ServerListMsg: { unschedule(schedule_selector(LoginLayerUC::scheduleForConnectGateServer)); CCLOG("ServerListMsg"); ServerList* serverInfo = (ServerList*)msg; m_serverInfo = *serverInfo; m_pLoading->setVisible(false); //没有服务器列表弹框提示 if(m_serverInfo.server_list().size()<=0) { ShowPopTextTip(GETLANGSTR(207)); return false; } //读取上一次登录选择的服务器 std::string sServerGame = CCUserDefault::sharedUserDefault()->getStringForKey(SERVER_FOR_GAME); m_iSelectServerIndex = getServerIndex(sServerGame); //读取更新服务器列表 std::string sUpdateServer = serverInfo->update_server(); if(sUpdateServer.compare("") != 0) { CCUserDefault::sharedUserDefault()->setStringForKey(SERVER_FOR_UPDATE, sUpdateServer); CCUserDefault::sharedUserDefault()->flush(); } //版本更新 bool bUpdate = GamePlatformMgr->VersionUpdateWithPlatform( serverInfo->game_version() ); if(!bUpdate) { initLogin(); } } break; case LoginResponseMsg: { LoginResponse *loginResponse = (LoginResponse *)msg; printf("%d,%d,",loginResponse->authrecode(),loginResponse->hasrole()); printf("\n name = %s ,...", loginResponse->GetDescriptor()->name().c_str()); int res =loginResponse->authrecode(); //登录成功, if (res==0) { if (loginResponse->hasrole()) { for (int i=0; i<loginResponse->rolelist_size();i++) { protos::common::Role role = loginResponse->rolelist(i); printf("role id:%d rolename:%s, rolelv: %d", role.roleid(), U8(role.rolename().c_str()),role.rolelv()); CNetClient::getShareInstance()->sendInGameReq(role.roleid()); break; } } else { m_armature->getAnimation()->play("enter"); this->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(0.7f), CCCallFunc::create(this, callfunc_selector(LoginLayerUC::callbackForSound)))); removeLogin(); } } //0x01服务器人数上限,0x02账号禁止登录,0x03账号验证错误) else if (res==1) { ShowTexttip(GETLANGSTR(227),RGB_RED,0,ccp(VCENTER.x,VCENTER.y+150),0.0f,2.0f,0.0f,20.0f); } else if (res==2) { ShowTexttip(GETLANGSTR(228),RGB_RED,0,ccp(VCENTER.x,VCENTER.y+150),0.0f,2.0f,0.0f,20.0f); } else if (res==3) { ShowTexttip(GETLANGSTR(165),RGB_RED,0,ccp(VCENTER.x,VCENTER.y+150),0.0f,2.0f,0.0f,20.0f); } else if(res==4) { ShowTexttip(GETLANGSTR(1155),RGB_RED,0,ccp(VCENTER.x,VCENTER.y+150),0.0f,2.0f,0.0f,20.0f); } return true; } break; //进入游戏 case InGameResponseMsg: { InGameResponse *inRespon = (InGameResponse*)msg; protos::common::Role role = inRespon->myrole(); printf("role id:%d rolename:%s, rolelv: %d", role.roleid(), U8(role.rolename().c_str()),role.rolelv()); UserData* userData = DataCenter::sharedData()->getUser()->getUserData(); userData->setRaceType(role.rolenation()); userData->setAliveID(role.roleid()); userData->setRoleID(role.roleid()); userData->setLevel(role.rolelv()); userData->setName(role.rolename().c_str()); userData->setCoin(role.rolecoin()); userData->setExp(role.roleexp()); userData->setNextExp(role.nextexp()); userData->setRoleAction(role.roleaction()); userData->setRoleGold(role.rolegold()); userData->read(role); m_armature->getAnimation()->play("enter"); this->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(0.7f), CCCallFunc::create(this, callfunc_selector(LoginLayerUC::callbackForSound)))); removeLogin(); return true; } break; default: break; } return false; }
void CDeviceView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) { CTreeView::OnUpdate(pSender, lHint, pHint); if( lHint == UPDATE_TAGS || lHint == UPDATE_TAG_VALUES ) return; CDoc* pDoc = GetDocument(); CTreeCtrl& tree = GetTreeCtrl(); switch( lHint ) { case CLEAR_ALL: deleting = TRUE; tree.DeleteAllItems(); deleting = FALSE; break; case UPDATE_ALL: case UPDATE_DEVICES: if( pHint ) { OTagGroup* pDevice = (OTagGroup*)pHint; ASSERT_KINDOF( OTagGroup, pDevice ); // find this item in the tree ASSERT( pDevice == (OTagGroup*)tree.GetItemData( pDevice->hItem ) ); // Set new stuff (name) tree.SetItem( pDevice->hItem, TVIF_TEXT, pDevice->name, 0, 0, 0, 0, 0 ); } else { deleting = TRUE; tree.DeleteAllItems(); deleting = FALSE; POSITION pos = pDoc->devices.groups.GetHeadPosition(); while( pos ) { OTagGroup* pDevice = pDoc->devices.groups.GetNext( pos ); pDevice->hItem = tree.InsertItem( pDevice->name, 1, 2 ); tree.SetItemData( pDevice->hItem, (DWORD)pDevice ); POSITION pos = pDevice->groups.GetHeadPosition(); while( pos ) { OTagGroup* pGroup = pDevice->groups.GetNext( pos ); pGroup->hItem = tree.InsertItem( pGroup->name, 3, 4, pDevice->hItem ); tree.SetItemData( pGroup->hItem, (DWORD)pGroup ); POSITION pos = pGroup->groups.GetHeadPosition(); while( pos ) { OTagGroup* pGroup2 = pGroup->groups.GetNext( pos ); pGroup2->hItem = tree.InsertItem( pGroup2->name, 3, 4, pGroup->hItem ); tree.SetItemData( pGroup2->hItem, (DWORD)pGroup2 ); POSITION pos = pGroup2->groups.GetHeadPosition(); while( pos ) { OTagGroup* pGroup3 = pGroup2->groups.GetNext( pos ); pGroup3->hItem = tree.InsertItem( pGroup3->name, 3, 4, pGroup2->hItem ); tree.SetItemData( pGroup3->hItem, (DWORD)pGroup3 ); } } } } if (1) { pos = servers.GetHeadPosition(); while( pos ) { OPCServerBase * p = servers.GetNext(pos); HTREEITEM h=tree.InsertItem( p->m_client, 1, 2 ); OPCGroupObject* pGroup = NULL; LPVOID key = 0; POSITION pos1 = p->m_groupMap.GetStartPosition(); while( pos1 ) { p->m_groupMap.GetNextAssoc( pos1, key, pGroup ); ASSERT( pGroup ); CString Str=pGroup->GetGroupName(); HTREEITEM h2=tree.InsertItem( Str, 1, 2, h); /** COPCItem* pItem = NULL; LPVOID key2 = 0; POSITION pos2 = pGroup->m_itemMap.GetStartPosition(); while( pos2 ) { pGroup->m_itemMap.GetNextAssoc( pos2, key2, pItem); ASSERT( pItem); CString Str=((CModbusItem*)pItem)->pTag->name; tree.InsertItem( Str, 1, 2, h2); } **/ } } } if( pDoc->pCurrent ) { tree.SelectItem( pDoc->pCurrent->hItem ); tree.EnsureVisible( pDoc->pCurrent->hItem ); } } break; case ADD_DEVICE: { OTagGroup* pDevice = (OTagGroup*)pHint; ASSERT_KINDOF( OTagGroup, pDevice ); ASSERT( pDevice->hItem == 0 ); HTREEITEM prevItem = TVI_ROOT; if( pDevice->parent != &pDoc->devices ) // this is a child { // look for previous group POSITION pos = pDevice->parent->groups.Find( pDevice ); if( pos ) { pDevice->parent->groups.GetPrev( pos ); // moves pointer back one if( pos ) { OTagGroup* pGroup = pDevice->parent->groups.GetAt( pos ); prevItem = pDevice->parent->groups.GetAt( pos )->hItem; } } pDevice->hItem = tree.InsertItem( pDevice->name, 3, 4, pDevice->parent->hItem, prevItem ); } else // insert at the root level { // look for previous device POSITION pos = pDoc->devices.groups.Find( pDevice ); if( pos ) { pDoc->devices.groups.GetPrev( pos ); // moves pointer back one if( pos ) { OTagGroup* pGroup = pDoc->devices.groups.GetAt( pos ); prevItem = pGroup->hItem; } } pDevice->hItem = tree.InsertItem( pDevice->name, 1, 2, TVI_ROOT, prevItem ); } tree.SetItemData( pDevice->hItem, (DWORD)pDevice ); tree.SelectItem( pDevice->hItem ); tree.EnsureVisible( pDevice->hItem ); } break; default: ASSERT( FALSE ); } }
void DryonBot::onPrivMsg(const string &sender, const string &dest, const string &msg) { vector<string> msg_parts; Tokenize(msg, msg_parts, " "); user_Info *usr; GET_USR(usr, sender); const string &command= msg_parts[0].substr(1); // load user flags from userfile.txt checkUserFlags(usr, dest); if( command=="reload" ) { /* if user has owner flag then reload all config files */ if( usr->hasFlag(USRLVL_OWNER) ) { // force update of user flags for(userDataTypeIter it= userData.begin(); it!= userData.end(); it++) (*it).second.flags_set= false; servers.loadFromFile("servers.txt"); userfile.saveFile(); userfile.readUserFile(); cfg.readFile(); PMgr.loadScriptsFromCfg(cfg); } return; } // user list else if( command=="userlist" ) { if( usr->hasAccount() && usr->hasFlag(USRLVL_OWNER) ) { map<string, UsersData> &ulist= userfile.getAccessList(); notice(sender, "User list: %d entries", ulist.size()); notice(sender, "-------- Start (Show accounts and global flags) --------"); for(map<string, UsersData>::iterator it= ulist.begin(); it!=ulist.end(); it++) { string what= it->first; if( (what[0]=='a') && (what[1]=='/') ) { what= '#' + what.substr(2); } notice(sender, "%15s %35s %5s", it->second.name.c_str(), what.c_str(), it->second.flags.c_str()); } notice(sender, "-------- End --------"); } return; } else if( command == "showflags" ) { if( usr->hasAccount() && usr->hasFlag(USRLVL_MASTER) ) { map<string, UsersData> &ulist= userfile.getAccessList(); string &chan= msg_parts[1]; notice(sender, "User list for %s", chan.c_str()); for(map<string, UsersData>::iterator it= ulist.begin(); it!=ulist.end(); it++) { string what= it->first; UsersData &tmp= it->second; for(map<string,string>::iterator it2= tmp.channel_flags.begin(); it2 != tmp.channel_flags.end(); it2++) { if( it2->first == chan ) notice(sender, "%15s %5s", it->second.name.c_str(), it2->second.c_str()); } } notice(sender, "-------- End --------"); } } // return a list of loaded plugins else if( command=="scripts" ) { uint count= PMgr.getPluginCount(); for(int i= count-1; i>= 0; i--) { notice(sender, "%2d ) %s\n", i, PMgr.getPlugin(i)->getPath()); } } else if( command=="quit" ) { if( usr->hasFlag(USRLVL_OWNER) ) { quit("exit requested"); } return; } else if( command=="help" ) { if( usr->hasAccount() ) { notice(sender, "Core commands:"); if( usr->hasFlag(USRLVL_OWNER) ) { notice(sender, ":reload - reload all plugins and config file"); notice(sender, ":userlist - display user list"); } notice(sender, ":help - display this :<"); notice(sender, ":scripts - display list of currently loaded scripts"); notice(sender, "---"); PMgr.sendCommandsList(sender, dest, usr); //return; } } else if( command=="nfo" ) { if( msg_parts.size() == 1 ) { Output("Nick: '%s'\n", bot_data.nick.c_str()); Output("Host: '%s'\n", bot_data.full_host.c_str()); Output("Auth: '%s'\n", bot_data.auth.c_str()); } else if( msg_parts.size() >= 2 ) { user_Info *u= getUserData(msg_parts[1]); if( u!=NULL ) { Output("Nick: '%s'\n", u->nick.c_str()); Output("Host: '%s'\n", u->full_host.c_str()); Output("Auth: '%s'\n", u->auth.c_str()); } else { notice(sender, "Nick unknown: %s", msg_parts[1].c_str()); } } } else { chan_Info *chan; if( isChannelName(dest) ) { GET_CHAN(chan, dest); PMgr.callEvent("event_onPrivMsg", "ucv", usr, chan, &msg_parts); PMgr.callCommand(usr, (dummy_Info*)chan, msg_parts); } else { PMgr.callEvent("event_onPrivMsg", "uuv", usr, &bot_data, &msg_parts); PMgr.callCommand(usr, (dummy_Info*)&bot_data, msg_parts); } } }
int main(int argc, char **argv) { int ret= 0; int ok= parseCommandLine(argc, argv); #if defined(DEBUG_MEM) atexit(_CheckMemLeaks); #endif #if defined(__FreeBSD__) //set_terminate( term_exception ); setlocale(LC_TIME, "fr_FR.ISO8859-1"); //signal(SIGINT, sigINT); signal(SIGPIPE, SIG_IGN); #elif defined(WIN32) setlocale(LC_TIME, "French"); WSAData wsaData; main_thread= GetCurrentThread(); console.run(); sleep(1); # if defined(_DEBUG) && defined(_MSC_VER) // add breakpoint when memory block n is allocated // _crtBreakAlloc //_CrtSetBreakAlloc(n); //_CrtSetBreakAlloc(10193); //_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF | // _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_DELAY_FREE_MEM_DF); # endif if( WSAStartup(MAKEWORD(1,1), &wsaData) != 0) { Error("Unable to initialise network: %d\n", WSAGetLastError()); } else { #endif Output("Dryon v" BOT_VERSION " compiled on " __DATE__ "\n"); Output("Embedded AMX: v" SMALL_VERSION "\n"); Output("Embedded Ruby: v" RUBY_VERSION "\n"); if( ok != 0 ) { usleep(10000); return 1; } if( help_mode ) { Output("Usage: %s [option(s)]\n", basename(argv[0])); Output("--test enable test mode\n"); Output("--help display help\n"); Output("--hidden start hidden (windows)\n"); Output("--config xxx set dryon.cfg file\n"); Output("--servers xxx set servers.txt file\n"); Output("--userfile xxx set userfile.txt file\n"); usleep(10000); return 0; } cfg.setFile( configfile_path.c_str() ); /* some checks on required folders/files */ if( makeSanityChecks() == 0 ) { bool err= false; cfg.readFile(); #define CHECK_CFG_VAR(X) if( !cfg.isDefined(#X) ){ Error("variable '" #X "' undefined\n"); err= true; } // check if required config directives are set CHECK_CFG_VAR( botname ); CHECK_CFG_VAR( alt_nick ); CHECK_CFG_VAR( realname ); CHECK_CFG_VAR( useauth ); CHECK_CFG_VAR( script_01); // if one or more vars are undefined then exit now // exit also if the compilation of scripts fails if( !err && (PMgr.loadScriptsFromCfg(cfg) == 0) ) { //// compile/test the scripts ///// if( test_mode ) { Output("** TEST MODE **\n"); PMgr.callEvent("event_onTest"); } /////////// else { string last_srv= "", srv= ""; cfg.readFile(); userfile.readUserFile( userfile_path.c_str() ); servers.loadFromFile( serverlist_path.c_str() ); while(1) { int ret; if( cfg.isDefined("debugmode") ) bot.setIntOption(OPTION_INT_DEBUGMODE, cfg.readIntKey("debugmode")); else bot.setIntOption(OPTION_INT_DEBUGMODE, 0); bot.setIntOption(OPTION_INT_USEAUTH, cfg.readBoolKey("useauth")?1:0); bot.setStrOption(OPTION_STR_REALNAME, cfg.readStringKey("realname")); bot.setStrOption(OPTION_STR_ALTNICK, cfg.readStringKey("alt_nick")); srv= servers.getNextServer(); // if the server is the same than the last one we tried, wait 2min // before trying to reconnect to be nice with the server :) if( srv == "" ) { Error("No servers in servers.txt, exiting...\n"); break; } else if( srv == last_srv ) { Debug("Waiting 2min before reconnect attempt...\n"); sleep(120); } // if exceptions occur then they came from the STL since // i don't use them try { ret= bot.mainLoop(srv, cfg.readStringKey("botname")); } catch( exception &e ) { Error("exception: %s\n", e.what()); } last_srv= srv; if( ret!=0 ) { Debug("Exiting...\n"); break; } PMgr.callEvent("event_onBotDisconnected"); } } } else { Output("Errors during loading/compilation\n"); ret= 1; } } else { ret= 1; } #if defined(WIN32) } #endif // i had problems when the bot exited immediatly from an error // the thread didn't had time to initialiase before exiting and this resulted // in a seg fault, with a small delay it works fine :) usleep(10000); #if defined(WIN32) WSACleanup(); Output("%sBot exited successfully, you can now close the window.%s\n", COLOR_GREEN, COLOR_RESET); // console.requestEnd(); // console.waitEnd(); #endif return ret; }
void AvailabilityModePanel::OnTestCompleted(bool abort) { TestMarshall *tm = TestMarshall::GetInstance(); wxString strKey; if( !abort ) { struct tcp_ping_arg_struct *tp = tm->GetTCPPingStruct(); struct icmp_ping_arg_struct *ip = tm->GetICMPPingStruct(); ResultLog *rlog = ResultLog::GetInstance(); StringValueList *row = new StringValueList(); row->Append( new wxString(wxDateTime::Now().Format( wxT("%Y-%m-%d %H:%M:%S") )) ); wxString *TCP_Connects = new wxString(); *TCP_Connects << (int)tp->connects; row->Append( TCP_Connects ); wxString *TCP_Hosts = new wxString(); *TCP_Hosts << (int)tp->number_hosts; row->Append( TCP_Hosts ); wxString *ICMP_Sent = new wxString(); *ICMP_Sent << (int)ip->packets_sent; row->Append( ICMP_Sent ); wxString *ICMP_Rec = new wxString(); *ICMP_Rec << (int)ip->packets_received; row->Append( ICMP_Rec ); wxString *ICMP_HostCount = new wxString(); *ICMP_HostCount << (int)ip->number_hosts; row->Append( ICMP_HostCount ); ServerList *slist = (ServerList*)ip->userdata; wxString ICMP_values; for( int i = 0 ; i < (int)ip->number_hosts ; i++ ) { Server *server = slist->Item( i )->GetData(); for( int ii = 0 ; ii < (int)ip->num_packets ; ii++ ) { struct valuestruct *vs = &ip->values[(i*(int)ip->num_packets)+ii]; ICMP_values << server->Host << wxT("|") << vs->timestamp.tv_sec << wxT("|") << vs->value << wxT("|"); } } wxString *ICMP_val = new wxString( ICMP_values.BeforeLast( wxT('|') ) ); row->Append( ICMP_val ); slist = (ServerList*)tp->userdata; wxString TCP_values; for( int i = 0 ; i < (int)tp->number_hosts ; i++ ) { struct valuestruct *vs = &tp->values[i]; Server *server = slist->Item( i )->GetData(); TCP_values << server->Host << wxT("|") << server->TCP_Port << wxT("|") << vs->timestamp.tv_sec << wxT("|") << vs->value << wxT("|"); } wxString *TCP_val = new wxString( TCP_values.BeforeLast( wxT('|') ) ); row->Append( TCP_val ); rlog->AddResult( wxT("availability"), *row ); RefreshResultList(); this->m_PageGraphResult->Refresh(); } tm->DeinitTestEngine(abort); PostTest(abort); }