aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/log
diff options
context:
space:
mode:
authorGravatar Elvio Basello2011-04-14 21:21:43 +0000
committerGravatar Elvio Basello2011-04-14 21:21:43 +0000
commitb051d48fd5eff9045d245aef9ec7b99b32fea375 (patch)
treecb4fe4725a9f5962a7d9bcdaf5f46f0f95656d4c /src/modules/log
parentAnother fix in theme module (diff)
downloadKVIrc-b051d48fd5eff9045d245aef9ec7b99b32fea375.tar.gz
KVIrc-b051d48fd5eff9045d245aef9ec7b99b32fea375.tar.bz2
KVIrc-b051d48fd5eff9045d245aef9ec7b99b32fea375.zip
added initial implementation of $log.export() (wip);
splitted LogFile class in its own files; added control procedure to call logview functions from log module git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5785 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/log')
-rw-r--r--src/modules/log/libkvilog.cpp76
1 files changed, 60 insertions, 16 deletions
diff --git a/src/modules/log/libkvilog.cpp b/src/modules/log/libkvilog.cpp
index 01cf3aa50..316116890 100644
--- a/src/modules/log/libkvilog.cpp
+++ b/src/modules/log/libkvilog.cpp
@@ -27,7 +27,7 @@
#include "KviApplication.h"
#include "KviLocale.h"
#include "KviIrcView.h"
-
+#include "KviModuleManager.h"
//#warning "log.stats"
//#warning "log.compress (gzip -r the log directory)"
@@ -101,7 +101,6 @@ static bool log_kvs_cmd_start(KviKvsModuleCommandCall * c)
c->warning(__tr2qs_ctx("Window '%Q' not found","log"),&szWindow);
return true;
}
-
} else {
c->warning(__tr2qs_ctx("Missing window id after the 'w' switch","log"));
return true;
@@ -110,11 +109,9 @@ static bool log_kvs_cmd_start(KviKvsModuleCommandCall * c)
if(pWnd->view())
{
-
if(szFile.isEmpty())
- {
pWnd->getDefaultLogFileName(szFile);
- }
+
if(!pWnd->view()->startLogging(szFile,c->hasSwitch('p',"log-buffer")))
c->warning(__tr2qs_ctx("Can't log to file '%Q'","log"),&szFile);
} else {
@@ -158,14 +155,14 @@ static bool log_kvs_cmd_stop(KviKvsModuleCommandCall * c)
c->warning(__tr2qs_ctx("Window '%Q' not found","log"),&szWindow);
return true;
}
-
} else {
c->warning(__tr2qs_ctx("Missing window id after the 'w' switch","log"));
return true;
}
}
- if(pWnd->view()) pWnd->view()->stopLogging();
+ if(pWnd->view())
+ pWnd->view()->stopLogging();
return true;
}
@@ -208,14 +205,14 @@ static bool log_kvs_cmd_flush(KviKvsModuleCommandCall * c)
c->warning(__tr2qs_ctx("Window '%Q' not found","log"),&szWindow);
return true;
}
-
} else {
c->warning(__tr2qs_ctx("Missing window id after the 'w' switch","log"));
return true;
}
}
- if(pWnd->view()) pWnd->view()->flushLog();
+ if(pWnd->view())
+ pWnd->view()->flushLog();
return true;
}
@@ -250,26 +247,72 @@ static bool log_kvs_cmd_flush(KviKvsModuleCommandCall * c)
*/
static bool log_kvs_fnc_file(KviKvsModuleFunctionCall * c)
{
- QString szWindow;
- QString buffer;
+ QString szWindow, szBuffer;
+
KVSM_PARAMETERS_BEGIN(c)
KVSM_PARAMETER("window id",KVS_PT_STRING,KVS_PF_OPTIONAL,szWindow)
KVSM_PARAMETERS_END(c)
- KviWindow * wnd = c->window();
+ KviWindow * pWnd = c->window();
if(!szWindow.isEmpty())
{
- wnd = g_pApp->findWindow(szWindow);
- if(!wnd)
+ pWnd = g_pApp->findWindow(szWindow);
+ if(!pWnd)
{
c->warning(__tr2qs_ctx("Window with id '%Q' not found, returning empty string","log"),&szWindow);
return true;
}
}
- if(wnd->view())wnd->view()->getLogFileName(buffer);
- c->returnValue()->setString(buffer);
+ if(pWnd->view())
+ pWnd->view()->getLogFileName(szBuffer);
+ c->returnValue()->setString(szBuffer);
+ return true;
+}
+
+/*
+ @doc: log.export
+ @type:
+ function
+ @title:
+ $log.export
+ @short:
+ Exports the specified log to the given format and returns the filename
+ @syntax:
+ <string> $log.export(<filename:string>[,<type:string>])
+ @description:
+
+ @example:
+ [example]
+ [cmd]echo[/cmd] $log.export([fnc]$log.file[/fnc],"html")
+ [/example]
+ @seealso:
+ [cmd]log.start[/cmd],
+ [cmd]log.stop[/cmd]
+*/
+static bool log_kvs_fnc_export(KviKvsModuleFunctionCall * c)
+{
+ QString szFile, szType;
+
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("filename",KVS_PT_NONEMPTYSTRING,0,szFile)
+ KVSM_PARAMETER("type",KVS_PT_STRING,KVS_PF_OPTIONAL,szType)
+ KVSM_PARAMETERS_END(c)
+
+ if(szType.isEmpty())
+ szType = "txt";
+
+ KviModule * m = g_pModuleManager->getModule("logview");
+ if(!m)
+ return false;
+
+ KviLogFileData log;
+ log.szName = szFile;
+ log.szType = szType;
+
+ m->ctrl("logview::export",(void *)&log);
+
return true;
}
@@ -280,6 +323,7 @@ static bool log_module_init(KviModule * m)
KVSM_REGISTER_SIMPLE_COMMAND(m,"flush",log_kvs_cmd_flush);
KVSM_REGISTER_FUNCTION(m,"file",log_kvs_fnc_file);
+ KVSM_REGISTER_FUNCTION(m,"export",log_kvs_fnc_export);
return true;
}