aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/spaste/libkvispaste.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/spaste/libkvispaste.cpp')
-rw-r--r--src/modules/spaste/libkvispaste.cpp128
1 files changed, 69 insertions, 59 deletions
diff --git a/src/modules/spaste/libkvispaste.cpp b/src/modules/spaste/libkvispaste.cpp
index 0f072a9b1..c47f9bfa8 100644
--- a/src/modules/spaste/libkvispaste.cpp
+++ b/src/modules/spaste/libkvispaste.cpp
@@ -39,7 +39,7 @@
#include <QClipboard>
#if !defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW)
- #include <unistd.h>
+#include <unistd.h>
#endif
KviPointerList<SlowPasteController> * g_pControllerList = 0;
@@ -47,25 +47,29 @@ int ctrlId = 0;
static SlowPasteController * spaste_find_controller(KviWindow * w)
{
- for(SlowPasteController * spc = g_pControllerList->first();spc;spc = g_pControllerList->next())
+ for(SlowPasteController * spc = g_pControllerList->first(); spc; spc = g_pControllerList->next())
{
- if(spc->window() == w)return spc;
+ if(spc->window() == w)
+ return spc;
}
return 0;
}
-static KviWindow * spaste_kvs_find_window(QString &win, KviKvsModuleCommandCall * c)
+static KviWindow * spaste_kvs_find_window(QString & win, KviKvsModuleCommandCall * c)
{
KviWindow * w;
- if(!win.isEmpty())w = g_pApp->findWindow(win);
- else w = c->window();
+ if(!win.isEmpty())
+ w = g_pApp->findWindow(win);
+ else
+ w = c->window();
if(!w)
{
- c->warning(__tr("Window with ID '%Q' not found"),&win);
+ c->warning(__tr("Window with ID '%Q' not found"), &win);
return 0;
}
- if((w->type() == KviWindow::Channel) || (w->type() == KviWindow::Query) || (w->type() == KviWindow::DccChat))return w;
- c->warning(__tr2qs("The specified window (%Q) is not a channel/query/DCC chat"),&win);
+ if((w->type() == KviWindow::Channel) || (w->type() == KviWindow::Query) || (w->type() == KviWindow::DccChat))
+ return w;
+ c->warning(__tr2qs("The specified window (%Q) is not a channel/query/DCC chat"), &win);
return 0;
}
@@ -92,14 +96,15 @@ static KviWindow * spaste_kvs_find_window(QString &win, KviKvsModuleCommandCall
static bool spaste_kvs_cmd_file(KviKvsModuleCommandCall * c)
{
- QString szFile,szWindow;
+ QString szFile, szWindow;
KVSM_PARAMETERS_BEGIN(c)
- KVSM_PARAMETER("file name",KVS_PT_STRING,0,szFile)
- KVSM_PARAMETER("window",KVS_PT_STRING,KVS_PF_OPTIONAL,szWindow)
+ KVSM_PARAMETER("file name", KVS_PT_STRING, 0, szFile)
+ KVSM_PARAMETER("window", KVS_PT_STRING, KVS_PF_OPTIONAL, szWindow)
KVSM_PARAMETERS_END(c)
- KviWindow * window = spaste_kvs_find_window(szWindow,c);
- if(!window)return false;
+ KviWindow * window = spaste_kvs_find_window(szWindow, c);
+ if(!window)
+ return false;
// FIXME
//if(szFile.isEmpty() || (!KviFileUtils::fileExists(szFile.toAscii())))
@@ -110,22 +115,24 @@ static bool spaste_kvs_cmd_file(KviKvsModuleCommandCall * c)
}
QFile tmp(szFile);
- if(!tmp.open(QIODevice::ReadOnly)) {
+ if(!tmp.open(QIODevice::ReadOnly))
+ {
c->warning(__tr2qs("I can't open that file"));
return false;
}
tmp.close();
SlowPasteController * controller = spaste_find_controller(window);
- if(!controller)controller = new SlowPasteController(window,++ctrlId);
- if(!controller->pasteFileInit(szFile)) {
+ if(!controller)
+ controller = new SlowPasteController(window, ++ctrlId);
+ if(!controller->pasteFileInit(szFile))
+ {
c->warning(__tr2qs("Could not paste file"));
return false;
}
return true;
}
-
/*
@doc: spaste.clipboard
@type:
@@ -154,13 +161,15 @@ static bool spaste_kvs_cmd_clipboard(KviKvsModuleCommandCall * c)
{
QString szWindow;
KVSM_PARAMETERS_BEGIN(c)
- KVSM_PARAMETER("window",KVS_PT_STRING,KVS_PF_OPTIONAL,szWindow)
+ KVSM_PARAMETER("window", KVS_PT_STRING, KVS_PF_OPTIONAL, szWindow)
KVSM_PARAMETERS_END(c)
- KviWindow * window = spaste_kvs_find_window(szWindow,c);
- if(!window)return false;
+ KviWindow * window = spaste_kvs_find_window(szWindow, c);
+ if(!window)
+ return false;
SlowPasteController * controller = spaste_find_controller(window);
- if(!controller)controller = new SlowPasteController(window,++ctrlId);
+ if(!controller)
+ controller = new SlowPasteController(window, ++ctrlId);
controller->pasteClipboardInit();
return true;
}
@@ -197,42 +206,43 @@ static bool spaste_kvs_cmd_clipboard(KviKvsModuleCommandCall * c)
static bool spaste_kvs_cmd_stop(KviKvsModuleCommandCall * c)
{
- kvs_uint_t iId=0;
+ kvs_uint_t iId = 0;
KVSM_PARAMETERS_BEGIN(c)
- KVSM_PARAMETER("delay",KVS_PT_UNSIGNEDINTEGER,KVS_PF_OPTIONAL,iId)
+ KVSM_PARAMETER("delay", KVS_PT_UNSIGNEDINTEGER, KVS_PF_OPTIONAL, iId)
KVSM_PARAMETERS_END(c)
- if(c->hasSwitch('a',"all")) //Delete all spaste's
+ if(c->hasSwitch('a', "all")) //Delete all spaste's
{
- while(g_pControllerList->first()) delete g_pControllerList->first();
+ while(g_pControllerList->first())
+ delete g_pControllerList->first();
return true;
}
KviPointerListIterator<SlowPasteController> it(*g_pControllerList);
- SlowPasteController *item;
+ SlowPasteController * item;
if(!iId) //Delete all spaste's from the current window
{
- if((c->window()->type() != KviWindow::Channel) &&
- (c->window()->type() != KviWindow::Query) &&
- (c->window()->type() != KviWindow::DccChat) &&
- (c->window()->type() != KviWindow::DeadChannel) &&
- (c->window()->type() != KviWindow::DeadQuery)
- )
+ if((c->window()->type() != KviWindow::Channel) && (c->window()->type() != KviWindow::Query) && (c->window()->type() != KviWindow::DccChat) && (c->window()->type() != KviWindow::DeadChannel) && (c->window()->type() != KviWindow::DeadQuery))
{
QString szWinId = c->window()->id();
- c->warning(__tr2qs("The specified window (%Q) is not a Channel/Query/DCC"),&szWinId);
+ c->warning(__tr2qs("The specified window (%Q) is not a Channel/Query/DCC"), &szWinId);
return false;
- } else {
- while( (item = it.current()) != 0)
+ }
+ else
+ {
+ while((item = it.current()) != 0)
{
++it;
- if(KviQString::equalCS(item->window()->id(),c->window()->id()))delete item;
+ if(KviQString::equalCS(item->window()->id(), c->window()->id()))
+ delete item;
}
}
- } else {
+ }
+ else
+ {
//Delete the spaste with the given id
- while( (item = it.current()) != 0)
+ while((item = it.current()) != 0)
{
++it;
if(item->getId() == (kvs_int_t)iId)
@@ -265,13 +275,13 @@ static bool spaste_kvs_cmd_stop(KviKvsModuleCommandCall * c)
static bool spaste_kvs_cmd_list(KviKvsModuleCommandCall * c)
{
KviPointerListIterator<SlowPasteController> it(*g_pControllerList);
- SlowPasteController *item;
+ SlowPasteController * item;
- while( (item = it.current()) != 0)
+ while((item = it.current()) != 0)
{
++it;
QString szWinId = item->window()->id();
- c->window()->output(KVI_OUT_NONE,__tr2qs("Slow-paste ID:%d Window:%Q"),item->getId(),&szWinId);
+ c->window()->output(KVI_OUT_NONE, __tr2qs("Slow-paste ID:%d Window:%Q"), item->getId(), &szWinId);
}
return true;
}
@@ -298,7 +308,7 @@ static bool spaste_kvs_cmd_setdelay(KviKvsModuleCommandCall * c)
{
kvs_int_t delay;
KVSM_PARAMETERS_BEGIN(c)
- KVSM_PARAMETER("delay",KVS_PT_INTEGER,0,delay)
+ KVSM_PARAMETER("delay", KVS_PT_INTEGER, 0, delay)
KVSM_PARAMETERS_END(c)
KVI_OPTION_UINT(KviOption_uintPasteDelay) = delay;
return true;
@@ -309,17 +319,18 @@ static bool spaste_module_init(KviModule * m)
g_pControllerList = new KviPointerList<SlowPasteController>;
g_pControllerList->setAutoDelete(false);
- KVSM_REGISTER_SIMPLE_COMMAND(m,"file",spaste_kvs_cmd_file);
- KVSM_REGISTER_SIMPLE_COMMAND(m,"clipboard",spaste_kvs_cmd_clipboard);
- KVSM_REGISTER_SIMPLE_COMMAND(m,"setdelay",spaste_kvs_cmd_setdelay);
- KVSM_REGISTER_SIMPLE_COMMAND(m,"stop",spaste_kvs_cmd_stop);
- KVSM_REGISTER_SIMPLE_COMMAND(m,"list",spaste_kvs_cmd_list);
+ KVSM_REGISTER_SIMPLE_COMMAND(m, "file", spaste_kvs_cmd_file);
+ KVSM_REGISTER_SIMPLE_COMMAND(m, "clipboard", spaste_kvs_cmd_clipboard);
+ KVSM_REGISTER_SIMPLE_COMMAND(m, "setdelay", spaste_kvs_cmd_setdelay);
+ KVSM_REGISTER_SIMPLE_COMMAND(m, "stop", spaste_kvs_cmd_stop);
+ KVSM_REGISTER_SIMPLE_COMMAND(m, "list", spaste_kvs_cmd_list);
return true;
}
static bool spaste_module_cleanup(KviModule *)
{
- while(g_pControllerList->first()) delete g_pControllerList->first();
+ while(g_pControllerList->first())
+ delete g_pControllerList->first();
delete g_pControllerList;
g_pControllerList = 0;
@@ -332,13 +343,12 @@ static bool spaste_module_can_unload(KviModule *)
}
KVIRC_MODULE(
- "SPaste", // module name
- "4.0.0", // module version
- "(C) 2002 Juanjo Alvarez (juanjux@yahoo.es)", // author & (C)
- "Delayed paste commands",
- spaste_module_init,
- spaste_module_can_unload,
- 0,
- spaste_module_cleanup,
- 0
-)
+ "SPaste", // module name
+ "4.0.0", // module version
+ "(C) 2002 Juanjo Alvarez (juanjux@yahoo.es)", // author & (C)
+ "Delayed paste commands",
+ spaste_module_init,
+ spaste_module_can_unload,
+ 0,
+ spaste_module_cleanup,
+ 0)