]> jfr.im git - irc/rizon/znc.git/commitdiff
Add CClient::PutStatus(const CTable&) and use it everywhere
authorpsychon <redacted>
Sun, 28 Sep 2008 12:05:49 +0000 (12:05 +0000)
committerpsychon <redacted>
Sun, 28 Sep 2008 12:05:49 +0000 (12:05 +0000)
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1222 726aef4b-f618-498e-8847-2d620e286838

Client.cpp
Client.h
ClientCommand.cpp
Modules.cpp

index 9258cd87036ff978ac8573da3cc72678e6e53a6b..e39a89daec28afc848a194f5cec752848b19a427 100644 (file)
@@ -717,6 +717,14 @@ void CClient::PutStatusNotice(const CString& sLine) {
        PutModNotice("status", sLine);
 }
 
+unsigned int CClient::PutStatus(const CTable& table) {
+       unsigned int idx = 0;
+       CString sLine;
+       while (table.GetLine(idx++, sLine))
+               PutStatus(sLine);
+       return idx - 1;
+}
+
 void CClient::PutStatus(const CString& sLine) {
        PutModule("status", sLine);
 }
index a6e8271fdf2d4f888045766e31c602594c9e4cd8..20813233c7f3acfbb9248c05e399cece8333a5ce 100644 (file)
--- a/Client.h
+++ b/Client.h
@@ -100,6 +100,7 @@ public:
 
        void PutIRC(const CString& sLine);
        void PutClient(const CString& sLine);
+       unsigned int PutStatus(const CTable& table);
        void PutStatus(const CString& sLine);
        void PutStatusNotice(const CString& sLine);
        void PutModule(const CString& sModule, const CString& sLine);
index 2a063a9b0af231f07291b6380a4ee30a30aaa172..c7d0bf81eab848154dc7040b7188db782fc5b1d1 100644 (file)
@@ -85,12 +85,7 @@ void CClient::UserCommand(const CString& sLine) {
                        Table.SetCell("Host", a->second->GetHost());
                }
 
-               unsigned int uTableIdx = 0;
-               CString sTmp;
-
-               while (Table.GetLine(uTableIdx++, sTmp)) {
-                       PutStatus(sTmp);
-               }
+               PutStatus(Table);
        } else if (sCommand.CaseCmp("DETACH") == 0) {
                if (m_pUser) {
                        CString sChan = sLine.Token(1);
@@ -163,14 +158,7 @@ void CClient::UserCommand(const CString& sLine) {
                                Table.SetCell("Host", vClients[a]->GetRemoteIP());
                        }
 
-                       if (Table.size()) {
-                               unsigned int uTableIdx = 0;
-                               CString sTmp;
-
-                               while (Table.GetLine(uTableIdx++, sTmp)) {
-                                       PutStatus(sTmp);
-                               }
-                       }
+                       PutStatus(Table);
                }
        } else if (m_pUser->IsAdmin() && sCommand.CaseCmp("LISTUSERS") == 0) {
                const map<CString, CUser*>& msUsers = CZNC::Get().GetUserMap();
@@ -194,14 +182,7 @@ void CClient::UserCommand(const CString& sLine) {
                        }
                }
 
-               if (Table.size()) {
-                       unsigned int uTableIdx = 0;
-                       CString sTmp;
-
-                       while (Table.GetLine(uTableIdx++, sTmp)) {
-                               PutStatus(sTmp);
-                       }
-               }
+               PutStatus(Table);
        } else if (m_pUser->IsAdmin() && sCommand.CaseCmp("SetMOTD") == 0) {
                CString sMessage = sLine.Token(1, true);
 
@@ -341,14 +322,7 @@ void CClient::UserCommand(const CString& sLine) {
                                }
                        }
 
-                       if (Table.size()) {
-                               unsigned int uTableIdx = 0;
-                               CString sTmp;
-
-                               while (Table.GetLine(uTableIdx++, sTmp)) {
-                                       PutStatus(sTmp);
-                               }
-                       }
+                       PutStatus(Table);
                }
        } else if (sCommand.CaseCmp("ADDSERVER") == 0) {
                CString sServer = sLine.Token(1);
@@ -407,14 +381,7 @@ void CClient::UserCommand(const CString& sLine) {
                                        Table.SetCell("Pass", pServer->GetPass());
                                }
 
-                               if (Table.size()) {
-                                       unsigned int uTableIdx = 0;
-                                       CString sTmp;
-
-                                       while (Table.GetLine(uTableIdx++, sTmp)) {
-                                               PutStatus(sTmp);
-                                       }
-                               }
+                               PutStatus(Table);
                        } else {
                                PutStatus("You don't have any servers added.");
                        }
@@ -435,14 +402,7 @@ void CClient::UserCommand(const CString& sLine) {
                                Table.SetCell("Topic", pChan->GetTopic());
                        }
 
-                       if (Table.size()) {
-                               unsigned int uTableIdx = 0;
-                               CString sTmp;
-
-                               while (Table.GetLine(uTableIdx++, sTmp)) {
-                                       PutStatus(sTmp);
-                               }
-                       }
+                       PutStatus(Table);
                }
        } else if (sCommand.CaseCmp("SEND") == 0) {
                CString sToNick = sLine.Token(1);
@@ -574,14 +534,7 @@ void CClient::UserCommand(const CString& sLine) {
                        }
                }
 
-               if (Table.size()) {
-                       unsigned int uTableIdx = 0;
-                       CString sTmp;
-
-                       while (Table.GetLine(uTableIdx++, sTmp)) {
-                               PutStatus(sTmp);
-                       }
-               } else {
+               if (PutStatus(Table) == 0) {
                        PutStatus("You have no active DCCs.");
                }
        } else if ((sCommand.CaseCmp("LISTMODS") == 0) || (sCommand.CaseCmp("LISTMODULES") == 0)) {
@@ -603,11 +556,7 @@ void CClient::UserCommand(const CString& sLine) {
                                        GTable.SetCell("Description", GModules[b]->GetDescription().Ellipsize(128));
                                }
 
-                               unsigned int uTableIdx = 0;
-                               CString sTmp;
-                               while (GTable.GetLine(uTableIdx++, sTmp)) {
-                                       PutStatus(sTmp);
-                               }
+                               PutStatus(GTable);
                        }
                }
 
@@ -628,11 +577,7 @@ void CClient::UserCommand(const CString& sLine) {
                                        Table.SetCell("Description", Modules[b]->GetDescription().Ellipsize(128));
                                }
 
-                               unsigned int uTableIdx = 0;
-                               CString sTmp;
-                               while (Table.GetLine(uTableIdx++, sTmp)) {
-                                       PutStatus(sTmp);
-                               }
+                               PutStatus(Table);
                        }
                }
 #else
@@ -666,12 +611,7 @@ void CClient::UserCommand(const CString& sLine) {
                                        GTable.SetCell("Description", Info.GetDescription().Ellipsize(128));
                                }
 
-                               unsigned int uTableIdx = 0;
-                               CString sTmp;
-
-                               while (GTable.GetLine(uTableIdx++, sTmp)) {
-                                       PutStatus(sTmp);
-                               }
+                               PutStatus(GTable);
                        }
                }
 
@@ -695,11 +635,7 @@ void CClient::UserCommand(const CString& sLine) {
                                        Table.SetCell("Description", Info.GetDescription().Ellipsize(128));
                                }
 
-                               unsigned int uTableIdx = 0;
-                               CString sTmp;
-                               while (Table.GetLine(uTableIdx++, sTmp)) {
-                                       PutStatus(sTmp);
-                               }
+                               PutStatus(Table);
                        }
                }
 #else
@@ -972,13 +908,7 @@ void CClient::UserCommand(const CString& sLine) {
                Table.SetCell("Out", CString::ToByteStr(users_total_out + CZNC::Get().BytesWritten()));
                Table.SetCell("Total", CString::ToByteStr(users_total_in + CZNC::Get().BytesRead() + users_total_out + CZNC::Get().BytesWritten()));
 
-               if (Table.size()) {
-                       unsigned int uTableIdx = 0;
-                       CString sTmp;
-                       while (Table.GetLine(uTableIdx++, sTmp)) {
-                               PutStatus(sTmp);
-                       }
-               }
+               PutStatus(Table);
        } else if (m_pUser->IsAdmin() && sCommand.CaseCmp("UPTIME") == 0) {
                PutStatus("Running for " + CZNC::Get().GetUptime());
        } else {
@@ -1200,12 +1130,5 @@ void CClient::HelpUser() {
                Table.SetCell("Description", "Restarts znc");
        }
 
-       if (Table.size()) {
-               unsigned int uTableIdx = 0;
-               CString sLine;
-
-               while (Table.GetLine(uTableIdx++, sLine)) {
-                       PutStatus(sLine);
-               }
-       }
+       PutStatus(Table);
 }
index de22a27cd465d165730af31ff610b156b27c332d..6469b48c0bbb0daea6e841db13bf95146b71a07c 100644 (file)
@@ -333,14 +333,7 @@ void CModule::ListTimers() {
                Table.SetCell("Description", pTimer->GetDescription());
        }
 
-       if (Table.size()) {
-               unsigned int uTableIdx = 0;
-               CString sLine;
-
-               while (Table.GetLine(uTableIdx++, sLine)) {
-                       PutModule(sLine);
-               }
-       }
+       PutModule(Table);
 }
 
 bool CModule::AddSocket(CSocket* pSocket) {
@@ -432,14 +425,7 @@ void CModule::ListSockets() {
                Table.SetCell("RemotePort", (pSocket->GetRemotePort()) ? CString(pSocket->GetRemotePort()) : CString(""));
        }
 
-       if (Table.size()) {
-               unsigned int uTableIdx = 0;
-               CString sLine;
-
-               while (Table.GetLine(uTableIdx++, sLine)) {
-                       PutModule(sLine);
-               }
-       }
+       PutModule(Table);
 }
 
 CString CModule::GetModNick() const { return ((m_pUser) ? m_pUser->GetStatusPrefix() : "*") + m_sModName; }