Diffstat (limited to 'noncore/applets/keyhelper/keyhelperapplet/anylnk/QCopLnk.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/applets/keyhelper/keyhelperapplet/anylnk/QCopLnk.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/QCopLnk.cpp b/noncore/applets/keyhelper/keyhelperapplet/anylnk/QCopLnk.cpp new file mode 100644 index 0000000..991bf87 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/QCopLnk.cpp | |||
@@ -0,0 +1,63 @@ | |||
1 | #include "QCopLnk.h" | ||
2 | #include "StringParser.h" | ||
3 | |||
4 | void QCopLnk::execute() | ||
5 | { | ||
6 | parseText(); | ||
7 | //QStringList argList = KHUtil::parseArgs(m_params[1]); | ||
8 | QStringList argList = StringParser::split(' ', m_params[1]); | ||
9 | if(argList.count() < 2){ | ||
10 | return; | ||
11 | } | ||
12 | QStringList paramList = | ||
13 | QStringList::split(QRegExp("[(),]"), argList[1]); | ||
14 | if(argList.count() < paramList.count()+1){ | ||
15 | return; | ||
16 | } | ||
17 | paramList.remove(paramList.begin()); | ||
18 | if(paramList.count() == 0){ | ||
19 | /* send qcop message */ | ||
20 | QCopEnvelope env(argList[0].latin1(), argList[1].latin1()); | ||
21 | } else { | ||
22 | QCopEnvelope* e = NULL; | ||
23 | QStringList::Iterator it=paramList.end(); | ||
24 | for(unsigned int index = 2; index<argList.count(); index++){ | ||
25 | if(it == paramList.end()){ | ||
26 | if(argList.count() - index < paramList.count()){ | ||
27 | break; | ||
28 | } | ||
29 | /* initialize */ | ||
30 | it = paramList.begin(); | ||
31 | e = new QCopEnvelope( | ||
32 | argList[0].latin1(), argList[1].latin1()); | ||
33 | } | ||
34 | QString arg = argList[index]; | ||
35 | if(*it == "QString"){ | ||
36 | *e << arg; | ||
37 | } else if(*it == "int"){ | ||
38 | *e << arg.toInt(); | ||
39 | } else if(*it == "bool"){ | ||
40 | QString s = arg.lower(); | ||
41 | int on; | ||
42 | if(s == "true"){ | ||
43 | on = TRUE; | ||
44 | } else if(s == "false"){ | ||
45 | on = FALSE; | ||
46 | } else { | ||
47 | on = s.toInt(); | ||
48 | } | ||
49 | *e << on; | ||
50 | } | ||
51 | ++it; | ||
52 | if(it == paramList.end()){ | ||
53 | /* send qcop message */ | ||
54 | delete e; | ||
55 | if(argList.count() - index >= paramList.count()){ | ||
56 | e = new QCopEnvelope( | ||
57 | argList[0].latin1(), argList[1].latin1()); | ||
58 | it = paramList.begin(); | ||
59 | } | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | } | ||