~ubuntu-branches/ubuntu/lucid/znc/lucid-backports

« back to all changes in this revision

Viewing changes to Chan.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2011-05-11 13:34:53 UTC
  • mfrom: (13.1.8 sid)
  • Revision ID: james.westby@ubuntu.com-20110511133453-334862gk6gh8dmwp
Tags: 0.092-3~lucid1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2004-2009  See the AUTHORS file for details.
 
2
 * Copyright (C) 2004-2010  See the AUTHORS file for details.
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify it
5
5
 * under the terms of the GNU General Public License version 2 as published
63
63
        if (!GetDefaultModes().empty())
64
64
                m_pUser->PrintLine(File, "\tModes", GetDefaultModes());
65
65
 
 
66
        MODULECALL(OnWriteChanConfig(File, *this), m_pUser, NULL,);
 
67
 
66
68
        File.Write("\t</Chan>\n");
67
69
        return true;
68
70
}
96
98
void CChan::JoinUser(bool bForce, const CString& sKey, CClient* pClient) {
97
99
        if (!bForce && (!IsOn() || !IsDetached())) {
98
100
                m_pUser->PutIRC("JOIN " + GetName() + " " + ((sKey.empty()) ? GetKey() : sKey));
 
101
                SetDetached(false);
99
102
                return;
100
103
        }
101
104
 
111
114
        CString sPerm, sNick;
112
115
 
113
116
        vector<CClient*>& vpClients = m_pUser->GetClients();
114
 
        for (vector<CClient*>::iterator it = vpClients.begin(); it != vpClients.end(); it++) {
 
117
        for (vector<CClient*>::iterator it = vpClients.begin(); it != vpClients.end(); ++it) {
115
118
                CClient* pThisClient;
116
119
                if (!pClient)
117
120
                        pThisClient = *it;
118
121
                else
119
122
                        pThisClient = pClient;
120
123
 
121
 
                for (map<CString,CNick*>::iterator a = m_msNicks.begin(); a != m_msNicks.end(); a++) {
 
124
                for (map<CString,CNick*>::iterator a = m_msNicks.begin(); a != m_msNicks.end(); ++a) {
122
125
                        if (pThisClient->HasNamesx()) {
123
126
                                sPerm = a->second->GetPermStr();
124
127
                        } else {
172
175
CString CChan::GetModeString() const {
173
176
        CString sModes, sArgs;
174
177
 
175
 
        for (map<unsigned char, CString>::const_iterator it = m_musModes.begin(); it != m_musModes.end(); it++) {
 
178
        for (map<unsigned char, CString>::const_iterator it = m_musModes.begin(); it != m_musModes.end(); ++it) {
176
179
                sModes += it->first;
177
180
                if (it->second.size()) {
178
181
                        sArgs += " " + it->second;
185
188
CString CChan::GetModeForNames() const {
186
189
        CString sMode;
187
190
 
188
 
        for (map<unsigned char, CString>::const_iterator it = m_musModes.begin(); it != m_musModes.end(); it++) {
 
191
        for (map<unsigned char, CString>::const_iterator it = m_musModes.begin(); it != m_musModes.end(); ++it) {
189
192
                if (it->first == 's') {
190
193
                        sMode = "@";
191
194
                } else if ((it->first == 'p') && sMode.empty()){
215
218
        CString sArgs = sModes.Token(1, true);
216
219
        bool bAdd = true;
217
220
 
218
 
#ifdef _MODULES
219
221
        CNick* pOpNick = FindNick(sOpNick);
220
222
 
221
223
        if (pOpNick) {
222
224
                MODULECALL(OnRawMode(*pOpNick, *this, sModeArg, sArgs), m_pUser, NULL, );
223
225
        }
224
 
#endif
225
226
 
226
227
        for (unsigned int a = 0; a < sModeArg.size(); a++) {
227
228
                const unsigned char& uMode = sModeArg[a];
250
251
                                                        RemPerm(uPerm);
251
252
                                                }
252
253
                                        }
253
 
#ifdef _MODULES
254
254
                                        bool bNoChange = (pNick->HasPerm(uPerm) == bAdd);
255
255
 
256
256
                                        if (uMode && pOpNick) {
270
270
                                                        }
271
271
                                                }
272
272
                                        }
273
 
#endif
274
273
                                }
275
274
                        }
276
275
                } else {
295
294
                                        break;
296
295
                        }
297
296
 
298
 
#ifdef _MODULES
299
297
                        bool bNoChange;
300
298
                        if (bList) {
301
299
                                bNoChange = false;
305
303
                                bNoChange = !HasMode(uMode);
306
304
                        }
307
305
                        MODULECALL(OnMode(*pOpNick, *this, uMode, sArg, bAdd, bNoChange), m_pUser, NULL, );
308
 
#endif
309
306
 
310
307
                        if (!bList) {
311
 
                                (bAdd) ? AddMode(uMode, sArg) : RemMode(uMode, sArg);
 
308
                                (bAdd) ? AddMode(uMode, sArg) : RemMode(uMode);
312
309
                        }
313
310
                }
314
311
        }
349
346
        return true;
350
347
}
351
348
 
352
 
bool CChan::RemMode(unsigned char uMode, const CString& sArg) {
 
349
bool CChan::RemMode(unsigned char uMode) {
353
350
        if (!HasMode(uMode)) {
354
351
                return false;
355
352
        }
365
362
}
366
363
 
367
364
void CChan::ClearNicks() {
368
 
        for (map<CString,CNick*>::iterator a = m_msNicks.begin(); a != m_msNicks.end(); a++) {
 
365
        for (map<CString,CNick*>::iterator a = m_msNicks.begin(); a != m_msNicks.end(); ++a) {
369
366
                delete a->second;
370
367
        }
371
368
 
379
376
 
380
377
        sNicks.Split(" ", vsNicks, false);
381
378
 
382
 
        for (it = vsNicks.begin(); it != vsNicks.end(); it++) {
 
379
        for (it = vsNicks.begin(); it != vsNicks.end(); ++it) {
383
380
                if (AddNick(*it)) {
384
381
                        iRet++;
385
382
                }
439
436
        map<char, unsigned int> mRet;
440
437
 
441
438
        map<CString,CNick*>::const_iterator it;
442
 
        for (it = m_msNicks.begin(); it != m_msNicks.end(); it++) {
 
439
        for (it = m_msNicks.begin(); it != m_msNicks.end(); ++it) {
443
440
                CString sPerms = it->second->GetPermStr();
444
441
 
445
442
                for (unsigned int p = 0; p < sPerms.size(); p++) {