-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
105 lines (89 loc) · 1.97 KB
/
main.c
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
#include <stdio.h>
#include <pthread.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <memory.h>
#include <time.h>
#include <lunaservice.h>
#include "vorec.h"
GMainLoop *loop;
LSPalmService *handle;
LSHandle *prv_service;
LSHandle *pub_service;
bool begin( LSHandle *handle, LSMessage *msg, void *ctx)
{
if(rec_begin())
{
LSMessageRespond( msg, "{\"returnValue\": true, \"Status\": true}", NULL);
return true;
}
else
LSMessageRespond( msg, "{\"returnValue\": true, \"Status\": false}", NULL);
return false;
}
bool stop( LSHandle *handle, LSMessage *msg, void *ctx)
{
if(rec_stop())
{
LSMessageRespond( msg, "{\"returnValue\": true, \"Status\": true}", NULL);
return true;
}
else
LSMessageRespond( msg, "{\"rerurnValue\": true, \"Status\": false}", NULL);
return false;
}
bool status( LSHandle *handle, LSMessage *msg, void *ctx)
{
if(rec_status())
{
LSMessageRespond( msg, "{\"returnValue\": true, \"Status\": true}", NULL);
return true;
}
else
LSMessageRespond( msg, "{\"rerurnValue\": true, \"Status\": false}", NULL);
return true;
}
static LSMethod methods[] =
{
{"recBegin", begin },
{"recStop", stop},
{"recStatus", status},
{ 0, 0}
};
bool service_register( const char *name)
{
bool rc;
LSError error;
LSErrorInit( &error);
loop = g_main_loop_new(NULL, FALSE);
if(loop == NULL)
goto end;
rc = LSRegisterPalmService(name, &handle, &error);
if(rc)
{
pub_service = LSPalmServiceGetPublicConnection(handle);
prv_service = LSPalmServiceGetPrivateConnection(handle);
}
else
goto end;
rc = LSPalmServiceRegisterCategory( handle, "/", methods, NULL, NULL,
NULL, &error);
LSGmainAttachPalmService( handle, loop, &error);
if(!rc)
goto end;
end:
if(LSErrorIsSet(&error))
{
LSErrorPrint(&error, stderr);
LSErrorFree(&error);
}
return rc;
}
int main( int argc, char *argv[])
{
mkdir( "/media/internal/record", 0);
service_register("chomper.service.recorder");
g_main_loop_run(loop);
}