moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kverbos / kverbos / kfeedercontrol.cpp
blobdaa4b9ab6581ca5e049fcae7c906f4bb68bdb928
1 /***************************************************************************
2 kfeedercontrol.cpp - description
3 -------------------
4 begin : Wed Apr 17 2002
5 copyright : (C) 2002 by Arnold Kraschinski
6 email : arnold.k67@gmx.de
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #include "kfeedercontrol.h"
20 #include <kapplication.h>
21 #include <kstandarddirs.h>
23 KFeederControl::KFeederControl(int ID, bool splash, bool automatic)
25 QString f = KStandardDirs::findExe("kfeeder");
26 QString s;
27 s.setNum(ID);
28 childFeeder << f;
29 if (splash)
30 childFeeder << "-s" << "yes";
31 else
32 childFeeder << "-s" << "no";
33 if (automatic)
34 childFeeder << "-m" << "automatic";
35 else
36 childFeeder << "-m" << "triggered";
37 if (!childFeeder.start())
38 active = false;
39 else
41 feederID.setNum(childFeeder.pid());
42 feederID = "KFeeder-" + feederID;
44 dcop = kapp->dcopClient();
45 dcop->attach();
46 appId = dcop->registerAs("KVerbos");
47 active = true;
51 KFeederControl::~KFeederControl()
55 // resets the KFeeder
56 bool KFeederControl::reset()
58 if (active)
60 QByteArray data; // "raw support" for data
61 QDataStream arg(data, IO_WriteOnly); // "container" provides
62 // easy access to data
63 int a_number = 1;
64 arg << a_number; // put information on the
65 // "support" in the "container"
66 lastResult = dcop->send(feederID, // identify the recipient
67 "kfeeder", //hierarchically designate
68 // the targeted object
69 "reset()", // signature of the method
70 // that will handle sent data
71 data); // the data
73 return active && lastResult;
76 bool KFeederControl::addOne()
78 if (active)
80 QByteArray data; // "raw support" for data
81 QDataStream arg(data, IO_WriteOnly); // "container" provides
82 // easy access to data
83 int a_number = 1;
84 arg << a_number; // put information on the
85 // "support" in the "container"
86 lastResult = dcop->send(feederID, // identify the recipient
87 "kfeeder", //hierarchically designate
88 // the targeted object
89 "addOne()", // signature of the method
90 // that will handle sent data
91 data); // the data
93 return active && lastResult;
96 bool KFeederControl::addN(int n)
98 if (active)
100 QByteArray data; // "raw support" for data
101 QDataStream arg(data, IO_WriteOnly); // "container" provides
102 // easy access to data
103 int a_number = n;
104 arg << a_number; // put information on the
105 // "support" in the "container"
106 lastResult = dcop->send(feederID, // identify the recipient
107 "kfeeder", // hierarchically designate
108 // the targeted object
109 "addN(int)", // signature of the method
110 // that will handle sent data
111 data); // the data
113 return active && lastResult;
116 // sets the type of food movement. 'true' the food is moved automatically.
117 // 'false' it is necessary to trigger the food movement. */
118 bool KFeederControl::setAutomatic(bool a)
120 if (active)
122 QByteArray data; // "raw support" for data
123 QDataStream arg(data, IO_WriteOnly); // "container" provides
124 // easy access to data
125 int num;
126 if (a)
127 num = 1; // put information on the
128 else
129 num = 0;
130 arg << num;
131 // "support" in the "container"
132 lastResult = dcop->send(feederID, // identify the recipient
133 "kfeeder", //hierarchically designate
134 // the targeted object
135 "setAutomatic(int)", // signature of the method
136 // that will handle sent data
137 data); // the data
139 return active && lastResult;