-
Notifications
You must be signed in to change notification settings - Fork 0
/
daemon.cpp
167 lines (156 loc) · 4.75 KB
/
daemon.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#include <ZConfig.h>
#include <qtimer.h>
#include <qdatetime.h>
#include "settingDlg.h"
#include "source.h"
#include "daemon.h"
#include "myapplication.h"
#include "megabox.h"
#include "codeComp.h"
extern Settings *cfg;
extern megabox *gui;
extern CDCP *codeComp;
Daemon::Daemon(QObject *parent)
: QObject(parent)
{
keycount = 0;
isDoHold = false;
}
Daemon::~Daemon()
{
#ifdef DEBUG
qDebug("====== delete daemon \n");
#endif
if( timer->isActive() )
timer->stop();
delete timer;
timer = NULL;
}
void Daemon::slotChannel(const QCString &msg,const QByteArray &data)
{
if(msg == "keyMsg(int,int)") // hardkey bc
{
QDataStream stream(data,IO_ReadOnly);
stream>>keycode>>status;
#ifdef DEBUG
cout<<"keycode "<<keycode<<" status "<<status<<endl;
#endif
if( (keycode==4168 && status==2) || (keycode==65285 && status==1) || (keycode==4147 && status==1) )
{
if(keycount < 5) {
if(codeComp->cpcp()) {
if(!cfg->cfg_shortMKeyToOpen) {
QCopChannel::send("/EZX/ROKRTOOLS","RaiseUI()");
} else
{
if( cfg->mKeyType == "")
launchAppObject( QString(musicUid) );
else
launchAppObject(cfg->mKeyType);
}
} else
{
qDebug("app opened, short music key to open app\n");
QCopChannel::send("/EZX/ROKRTOOLS","RaiseUI()");
}
}
keycount = 0;
isDoHold = false;
}
if(keycode == 4147 && status == 4) {
if(codeComp->cpcp()) {
if(!cfg->cfg_shortMKeyToOpen) {
if( cfg->mKeyType == "")
launchAppObject( QString(musicUid) );
else
launchAppObject(cfg->mKeyType);
}
else
QCopChannel::send("/EZX/ROKRTOOLS","RaiseUI()");
} else
{
launchAppObject(musicUid);
}
}
//key hold
if(keycode == 4168 && status == 268435457)
{
keycount++;
if(keycount >= 5) {
if(!isDoHold) {
if(codeComp->cpcp()) {
if(!cfg->cfg_shortMKeyToOpen) {
if( cfg->mKeyType == "")
launchAppObject( QString(musicUid) );
else
launchAppObject(cfg->mKeyType);
} else
{
QCopChannel::send("/EZX/ROKRTOOLS","RaiseUI()");
}
} else
{
launchAppObject(musicUid);
}
isDoHold = true;
}
}
}
}
if (msg == "LCDOn")
{
if(cfg->cpuLockType != "0")
{
system("pmtool -d 0");
system( QString("echo %1 > /sys/mpm/op").arg(cfg->cpuLockType) );
}
}
if (msg == "LCDOff")
{
if(cfg->cpuLockType != "0")
system("pmtool -d 1");
}
if(msg == "FreeCpu()")
{
if ( !timer->isActive() ) {
timer->start(3000, true);
}
else {
timer->stop();
timer->start(3000, true);
}
}
if(msg == "LockCpu()")
{
if( !timer->isActive() ) {
system("pmtool -d 1");
system("pmtool -d 0");
system( QString("echo 532 > /sys/mpm/op") );
}
}
}
void Daemon::slotUpdateTimer()
{
if(cfg->cpuLockType != "0") {
system("pmtool -d 1");
system("pmtool -d 0");
system( QString("echo %1 > /sys/mpm/op").arg(cfg->cpuLockType) );
}
else {
system("pmtool -d 1");
}
}
void Daemon::run()
{
#ifdef DEBUG
qDebug("====== start daemon \n");
#endif
QCopChannel *bcchnl = new QCopChannel("/hardkey/bc", this);
connect(bcchnl,SIGNAL(received(const QCString &,const QByteArray &)),this,SLOT(slotChannel(const QCString &,const QByteArray &)));
QCopChannel *syschnl = new QCopChannel("EZX/System", this);
connect(syschnl,SIGNAL(received(const QCString &,const QByteArray &)),this,SLOT(slotChannel(const QCString &,const QByteArray &)));
QCopChannel *marschnl = new QCopChannel("/EZX/marsRtChnl", this);
connect(marschnl,SIGNAL(received(const QCString &,const QByteArray &)),this,SLOT(slotChannel(const QCString &,const QByteArray &)));
timer = new QTimer(this);
connect( timer, SIGNAL( timeout() ), this, SLOT( slotUpdateTimer() ) );
}