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

« back to all changes in this revision

Viewing changes to src/modules/spaste/libkvispaste.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kai Wasserbäch, Kai Wasserbäch, Raúl Sánchez Siles
  • Date: 2011-02-12 10:40:21 UTC
  • mfrom: (14.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110212104021-5mh4f75jlku20mnt
The combined "Twisted Experiment" and "Nocturnal Raid" release.

[ Kai Wasserbäch ]
* Synced to upstream's SVN revision 5467.
* debian/rules:
  - Added .PHONY line.
  - Resurrect -DMANUAL_REVISION, got lost somewhere and we build SVN
    revisions again.
  - Replace "-DWITH_NO_EMBEDDED_CODE=YES" with "-DWANT_CRYPTOPP=YES".
  - Change the remaining -DWITH/-DWITHOUT to the new -DWANT syntax.
* debian/control:
  - Removed DMUA, I'm a DD now.
  - Changed my e-mail address.
  - Removed unneeded relationships (no upgrades over two releases are
    supported).
  - Fix Suggests for kvirc-dbg.
  - kvirc-data: Make the "Suggests: kvirc" a Recommends, doesn't make much
    sense to install the -data package without the program.
* debian/source/local-options: Added with "unapply-patches".
* debian/kvirc.lintian-overrides: Updated to work for 4.1.1.
* debian/patches/21_make_shared-mime-info_B-D_superfluous.patch: Updated.
* debian/kvirc-data.install: Added .notifyrc.

[ Raúl Sánchez Siles ]
* Stating the right version where kvirc-data break and replace should happen.
* Fixing link to license file.
* Added French and Portuguese man pages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
//   File : libkvispaste.cpp
4
4
//   Creation date : Thu Dec 27 2002 17:13:12 GMT by Juanjo �lvarez
5
5
//
6
 
//   This file is part of the KVirc irc client distribution
 
6
//   This file is part of the KVIrc irc client distribution
7
7
//   Copyright (C) 2002 Juanjo �lvarez (juanjux@yahoo.es)
8
 
//   Copyright (C) 2002-2008 Szymon Stefanek (kvirc@tin.it)
 
8
//   Copyright (C) 2002-2010 Szymon Stefanek (kvirc@tin.it)
9
9
//
10
10
//   This program is FREE software. You can redistribute it and/or
11
11
//   modify it under the terms of the GNU General Public License
24
24
//=============================================================================
25
25
 
26
26
#include "libkvispaste.h"
27
 
#include "controller.h"
 
27
#include "SlowPasteController.h"
28
28
 
29
 
#include "kvi_module.h"
30
 
#include "kvi_fileutils.h"
31
 
#include "kvi_qstring.h"
32
 
#include "kvi_app.h"
33
 
#include "kvi_locale.h"
34
 
#include "kvi_console.h"
35
 
#include "kvi_options.h"
 
29
#include "KviModule.h"
 
30
#include "KviFileUtils.h"
 
31
#include "KviQString.h"
 
32
#include "KviApplication.h"
 
33
#include "KviLocale.h"
 
34
#include "KviConsoleWindow.h"
 
35
#include "KviOptions.h"
36
36
#include "kvi_out.h"
37
37
 
38
38
#include <QFile>
42
42
    #include <unistd.h>
43
43
#endif
44
44
 
45
 
KviPointerList<SPasteController> * g_pControllerList = 0;
 
45
KviPointerList<SlowPasteController> * g_pControllerList = 0;
46
46
int ctrlId = 0;
47
47
 
48
 
static SPasteController * spaste_find_controller(KviWindow * w)
 
48
static SlowPasteController * spaste_find_controller(KviWindow * w)
49
49
{
50
 
        for(SPasteController * spc = g_pControllerList->first();spc;spc = g_pControllerList->next())
 
50
        for(SlowPasteController * spc = g_pControllerList->first();spc;spc = g_pControllerList->next())
51
51
        {
52
52
                if(spc->window() == w)return spc;
53
53
        }
64
64
                c->warning(__tr("Window with ID '%Q' not found"),&win);
65
65
                return 0;
66
66
        }
67
 
        if((w->type() == KVI_WINDOW_TYPE_CHANNEL) || (w->type() == KVI_WINDOW_TYPE_QUERY) || (w->type() == KVI_WINDOW_TYPE_DCCCHAT))return w;
 
67
        if((w->type() == KviWindow::Channel) || (w->type() == KviWindow::Query) || (w->type() == KviWindow::DccChat))return w;
68
68
        c->warning(__tr2qs("The specified window (%Q) is not a channel/query/DCC chat"),&win);
69
69
        return 0;
70
70
}
116
116
        }
117
117
        tmp.close();
118
118
 
119
 
        SPasteController * controller = spaste_find_controller(window);
120
 
        if(!controller)controller = new SPasteController(window,++ctrlId);
 
119
        SlowPasteController * controller = spaste_find_controller(window);
 
120
        if(!controller)controller = new SlowPasteController(window,++ctrlId);
121
121
        if(!controller->pasteFileInit(szFile)) {
122
122
                c->warning(__tr2qs("Could not paste file"));
123
123
                return false;
159
159
        KviWindow * window = spaste_kvs_find_window(szWindow,c);
160
160
        if(!window)return false;
161
161
 
162
 
        SPasteController * controller = spaste_find_controller(window);
163
 
        if(!controller)controller = new SPasteController(window,++ctrlId);
 
162
        SlowPasteController * controller = spaste_find_controller(window);
 
163
        if(!controller)controller = new SlowPasteController(window,++ctrlId);
164
164
        controller->pasteClipboardInit();
165
165
        return true;
166
166
}
206
206
        {
207
207
                while(g_pControllerList->first()) delete g_pControllerList->first();
208
208
                return true;
209
 
        } else {
210
 
                KviPointerListIterator<SPasteController> it(*g_pControllerList);
211
 
                SPasteController *item;
212
 
 
213
 
                if(!iId) //Delete all spaste's from the current window
 
209
        }
 
210
 
 
211
        KviPointerListIterator<SlowPasteController> it(*g_pControllerList);
 
212
        SlowPasteController *item;
 
213
 
 
214
        if(!iId) //Delete all spaste's from the current window
 
215
        {
 
216
                if((c->window()->type() != KviWindow::Channel) && (c->window()->type() != KviWindow::Query) && (c->window()->type() != KviWindow::DccChat))
214
217
                {
215
 
                        if((c->window()->type() != KVI_WINDOW_TYPE_CHANNEL) && (c->window()->type() != KVI_WINDOW_TYPE_QUERY) && (c->window()->type() != KVI_WINDOW_TYPE_DCCCHAT))
216
 
                        {
217
 
                                QString szWinId = c->window()->id();
218
 
                                c->warning(__tr2qs("The specified window (%Q) is not a channel/query/dcc"),&szWinId);
219
 
                                return false;
220
 
                        } else {
221
 
                                while( (item = it.current()) != 0)
222
 
                                {
223
 
                                        ++it;
224
 
                                        if(KviQString::equalCS(item->window()->id(),c->window()->id()))delete item;
225
 
                                }
226
 
                        }
 
218
                        QString szWinId = c->window()->id();
 
219
                        c->warning(__tr2qs("The specified window (%Q) is not a channel/query/dcc"),&szWinId);
 
220
                        return false;
227
221
                } else {
228
 
                        //Delete the spaste with the given id
229
222
                        while( (item = it.current()) != 0)
230
223
                        {
231
224
                                ++it;
232
 
                                if(item->getId() == iId)delete item;
 
225
                                if(KviQString::equalCS(item->window()->id(),c->window()->id()))delete item;
233
226
                        }
234
227
                }
235
 
                return true;
 
228
        } else {
 
229
                //Delete the spaste with the given id
 
230
                while( (item = it.current()) != 0)
 
231
                {
 
232
                        ++it;
 
233
                        if(item->getId() == (kvs_int_t)iId)
 
234
                                delete item;
 
235
                }
236
236
        }
 
237
        return true;
237
238
}
238
239
 
239
240
/*
258
259
 
259
260
static bool spaste_kvs_cmd_list(KviKvsModuleCommandCall * c)
260
261
{
261
 
        KviPointerListIterator<SPasteController> it(*g_pControllerList);
262
 
        SPasteController *item;
 
262
        KviPointerListIterator<SlowPasteController> it(*g_pControllerList);
 
263
        SlowPasteController *item;
263
264
 
264
265
        while( (item = it.current()) != 0)
265
266
        {
300
301
 
301
302
static bool spaste_module_init(KviModule * m)
302
303
{
303
 
        g_pControllerList = new KviPointerList<SPasteController>;
 
304
        g_pControllerList = new KviPointerList<SlowPasteController>;
304
305
        g_pControllerList->setAutoDelete(false);
305
306
 
306
307
        KVSM_REGISTER_SIMPLE_COMMAND(m,"file",spaste_kvs_cmd_file);