DBus helper macros.
More...
#include "oyranos.h"
#include <dbus/dbus.h>
#include <unistd.h>
DBus helper macros.
Oyranos is an open source Color Management System
- Copyright:
- 2017 (C) Kai-Uwe Behrmann
- Author
- Kai-Uwe Behrmann ku.b@.nosp@m.gmx..nosp@m.de
- License:
- new BSD http://www.opensource.org/licenses/BSD-3-Clause
- Since
- 2017/09/27
The file contains some macros and boilerplate for DBus updates from settings changes. A direct dependency in the Oyranos libraries can not be cross platform and thus is not desireable.
Defined are DBus callback and functions, oyJob_s callbacks:
int config_state_changed = 0;
and some Boiler Plate to place before and to be called inside the used loop: oyStartDBusObserver, oyLoopDBusObserver
◆ oyCallbackDBusCli_m
#define oyCallbackDBusCli_m |
( |
|
check_var | ) |
|
Value:static void oyCallbackDBus ( double progress_zero_till_one, \
char * status_text, \
int thread_id_, \
int job_id, \
{ fprintf( stderr,"%s():%d %02f %s %d/%d\n",__func__,__LINE__, \
progress_zero_till_one, \
status_text?status_text:"",thread_id_,job_id); \
\
check_var = 1; \
}
Oyranos base structure.
Definition: oyStruct_s.h:78
oyJob_s::cb_progress for the main thread;
will be called inside oyJobResult()
◆ oyDBusFilter_m
◆ oyDbusReceiveMessage_m
#define oyDbusReceiveMessage_m |
borrowed from libelektra project receivemessage.c BSD License
◆ oyFinishDBus_m
Value:static int oyFinishDBus(
oyJob_s * job ) \
{ \
char * t = NULL; \
if(job->cb_progress) \
{ \
if(tmp) \
{ \
t = (char*) malloc(80+strlen(__func__)+strlen(tmp)); \
sprintf( t, "%s():%d --->\n%s\n<--- finished", __func__,__LINE__, tmp ); \
} \
\
oyMsg_Add(job, 0.9, &t); \
} \
return 0; \
}
const char * oyOption_GetRegistration(oyOption_s *option)
get the registration
Definition: oyOption_s.c:848
Asynchron job ticket.
Definition: oyranos_threads.h:46
Option object.
Definition: oyOption_s.h:148
oyJob_s::finish for the main thread
◆ oyLoopDBusObserver
#define oyLoopDBusObserver |
( |
|
hour, |
|
|
|
repeat_hour, |
|
|
|
check_var, |
|
|
|
update |
|
) |
| |
Value:double hour_diff = hour_old - hour; \
\
if(hour_diff < 0.0) \
hour_diff += 24.0; \
if(hour_diff > 12) \
hour_diff = 24.0 - hour_diff; \
\
\
oyJobResult(); \
\
if(check_var || hour_diff > repeat_hour ) \
\
{ \
error = update; \
hour_old = hour; \
} \
\
\
check_var = 0;
poll for updates double hour: current time double repeat_hour: repeat a full update in h int check_var: 1 means check, 0 means no check needed function update: will be called, when check_var is 1
◆ oyStartDBusObserver
#define oyStartDBusObserver |
( |
|
watch_, |
|
|
|
finish_, |
|
|
|
callback_, |
|
|
|
key_fragment, |
|
|
|
cb_context_ |
|
) |
| |
Value: \
\
job->work = watch_; \
\
job->finish = finish_; \
oyOption_SetFromString( o, key_fragment, 0 ); \
\
job->cb_progress = callback_; \
job->cb_progress_context = (
oyStruct_s*)cb_context_; \
id =
oyJob_Add( &job, 0, oyJOB_ADD_PERSISTENT_JOB );
oyOption_s * oyOption_FromRegistration(const char *registration, oyObject_s object)
new option with registration and value filled from DB if available
Definition: oyOption_s.c:122
oyJob_Add_f oyJob_Add
Add one unique oyJob_s to the job qeue.
Definition: oyranos_threads.c:202
oyJob_s * oyJob_New(oyObject_s object OY_UNUSED)
Allocate a new oyJob_s object.
Definition: oyranos_threads.c:298
Oyranos base structure.
Definition: oyStruct_s.h:78
setup the thread running the DBus observer simple version: oyStartDBusObserver( oyWatchDBus, oyFinishDBus, oyCallbackDBus, OY_STD )
◆ oyWatchDBus_m
#define oyWatchDBus_m |
( |
|
filter_function | ) |
|
Value:oyDbusReceiveMessage_m \
static
int oyWatchDBus(
oyJob_s * job ) \
{ \
char * t = NULL; \
if(job->cb_progress) \
{ \
if(tmp) \
{ \
t = (char*) malloc(80+strlen(__func__)+strlen(tmp)); \
sprintf( t, "%s():%d --->\n%s", __func__,__LINE__, tmp ); \
} \
\
oyMsg_Add(job, .1, &t); \
oyDbusReceiveMessage(DBUS_BUS_SESSION, filter_function, job); \
} \
return 0; \
}
const char * oyOption_GetRegistration(oyOption_s *option)
get the registration
Definition: oyOption_s.c:848
Asynchron job ticket.
Definition: oyranos_threads.h:46
Option object.
Definition: oyOption_s.h:148
covers oyDbusReceiveMessage_m oyJob_s::work for the processing thread