1 /***************************************************************************
2 kfeedercontrol.cpp - description
4 begin : Wed Apr 17 2002
5 copyright : (C) 2002 by Arnold Kraschinski
6 email : arnold.k67@gmx.de
7 ***************************************************************************/
9 /***************************************************************************
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. *
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");
30 childFeeder
<< "-s" << "yes";
32 childFeeder
<< "-s" << "no";
34 childFeeder
<< "-m" << "automatic";
36 childFeeder
<< "-m" << "triggered";
37 if (!childFeeder
.start())
41 feederID
.setNum(childFeeder
.pid());
42 feederID
= "KFeeder-" + feederID
;
44 dcop
= kapp
->dcopClient();
46 appId
= dcop
->registerAs("KVerbos");
51 KFeederControl::~KFeederControl()
56 bool KFeederControl::reset()
60 QByteArray data
; // "raw support" for data
61 QDataStream
arg(data
, IO_WriteOnly
); // "container" provides
62 // easy access to data
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
73 return active
&& lastResult
;
76 bool KFeederControl::addOne()
80 QByteArray data
; // "raw support" for data
81 QDataStream
arg(data
, IO_WriteOnly
); // "container" provides
82 // easy access to data
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
93 return active
&& lastResult
;
96 bool KFeederControl::addN(int n
)
100 QByteArray data
; // "raw support" for data
101 QDataStream
arg(data
, IO_WriteOnly
); // "container" provides
102 // easy access to data
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
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
)
122 QByteArray data
; // "raw support" for data
123 QDataStream
arg(data
, IO_WriteOnly
); // "container" provides
124 // easy access to data
127 num
= 1; // put information on the
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
139 return active
&& lastResult
;