~ubuntu-branches/ubuntu/trusty/kvirc/trusty

« back to all changes in this revision

Viewing changes to src/kvirc/kvs/KviKvsCoreSimpleCommands.cpp

  • Committer: Package Import Robot
  • Author(s): Kai Wasserbäch
  • Date: 2011-09-29 16:27:07 UTC
  • mfrom: (0.3.15 upstream)
  • Revision ID: package-import@ubuntu.com-20110929162707-t29s6itjnsg2syuf
Tags: 4:4.1.3+20110929.svn5980-1
The "Balance of Power" release.

* Synced to upstream's SVN revision 5980.
* debian/control:
  - Vcs-* fields updated.
  - Remove libcrypto++-dev from B-Ds, was dropped upstream.
  - Bumped B-D on debhelper to >= 8.9.4.
* debian/rules:
  - Remove a now obsolete flag.
  - Upstream fixed a typo in a configuration variable name (now
    WANT_COEXISTENCE), updated invocation.
* debian/compat: Now at 9.
* Make KVIrc multiarch ready:
  - debian/{kvirc,libkvilib4,kvirc-modules}.install: Split out binaries
    under /usr/lib.
  - debian/rules: Add -DLIB_SUFFIX to dh_auto_configure invocation.
  - debian/control:
    + Added new packages (needed for split).
    + Added Multi-Arch fields
    + Added Pre-Depends: multiarch-support and ${misc:Pre-Depends} where
      needed.
    + Bumped B-D on CMake.
  - debian/{kvirc,libkvilib4,kvirc-modules}.lintian-overrides: Moved and
    updated overrides to match new locations (one could be dropped in the
    process).

Show diffs side-by-side

added added

removed removed

Lines of Context:
169
169
                QByteArray szTarget = KVSCSC_pConnection->encodeText(KVSCSC_pWindow->windowName());
170
170
                QByteArray szMessage;
171
171
 
172
 
                int i = 0;
 
172
                int iMaxModeChangesPerLine = 3; // a good default
 
173
                KviIrcConnectionServerInfo * pServerInfo = KVSCSC_pConnection->serverInfo();
 
174
                if(pServerInfo)
 
175
                {
 
176
                        iMaxModeChangesPerLine = pServerInfo->maxModeChanges();
 
177
                        if(iMaxModeChangesPerLine < 1)
 
178
                                iMaxModeChangesPerLine = 1;
 
179
                }
 
180
 
 
181
                int iCurModeChangesPerLine = iMaxModeChangesPerLine;
 
182
                
 
183
                // Calculate the max number of available characters in a MODE command
 
184
                // 512 (max) - 2 (cr, lf) - 4 (MODE) - 3 (spaces) - 1 (plus/minus)
 
185
                // since we already know the channel name, take it in account, too
 
186
 
 
187
                const int iMaxCharsPerLine = 502 - szTarget.size();
 
188
                int iCurCharsPerLine = iMaxCharsPerLine;
 
189
                
173
190
                for(QStringList::Iterator it = sl.begin();it != sl.end();++it)
174
191
                {
175
192
                        QByteArray szTxt = KVSCSC_pConnection->encodeText(*it);
176
193
                        if(!szTxt.isEmpty())
177
194
                        {
178
195
                                szFlags += flag;
179
 
                                if(szMessage.length() > 0)szMessage += " ";
 
196
                                iCurCharsPerLine--;
 
197
 
 
198
                                if(szMessage.length() > 0)
 
199
                                {
 
200
                                        szMessage += " ";
 
201
                                        iCurCharsPerLine--;
 
202
                                }
 
203
                                
180
204
                                szMessage += szTxt;
181
 
                                i++;
182
 
                                if(i >= KVSCSC_pConnection->serverInfo()->maxModeChanges())
 
205
                                iCurCharsPerLine-=szTxt.size();
 
206
 
 
207
                                iCurModeChangesPerLine--;
 
208
                                if(iCurModeChangesPerLine < 0 || iCurCharsPerLine < 0)
183
209
                                {
184
210
                                        if(!KVSCSC_pConnection->sendFmtData("MODE %s %c%s %s",szTarget.data(),plusminus,szFlags.data(),szMessage.data()))
185
211
                                                return KVSCSC_pContext->warningNoIrcConnection();
186
 
                                        i = 0;
 
212
                                        
 
213
                                        // move back the iterator by one position
 
214
                                        // WARNING: this could lead to an infinite loop if a single specified mode
 
215
                                        // change is longer than iMaxCharsPerLine
 
216
                                        it--;
 
217
 
 
218
                                        // reset cycle variables
 
219
                                        iCurCharsPerLine = iMaxCharsPerLine;
 
220
                                        iCurModeChangesPerLine = iMaxModeChangesPerLine;
187
221
                                        szFlags = "";
188
222
                                        szMessage = "";
 
223
 
189
224
                                }
190
225
                        }
191
226
                }
192
227
 
193
 
                if(i > 0)
 
228
                if(iCurModeChangesPerLine != iMaxModeChangesPerLine)
194
229
                {
195
230
                        if(!KVSCSC_pConnection->sendFmtData("MODE %s %c%s %s",szTarget.data(),plusminus,szFlags.data(),szMessage.data()))
196
231
                                return KVSCSC_pContext->warningNoIrcConnection();