libusermetrics
MetricManagerAdvancedCAPI.c

A more advanced metric that updates the history of a metric. Usually this would be a metric from an external data source, e.g. e-mail or Facebook messages.

int main(int argc, char *argv[]) {
// We start with a manager object.
// This can be used as a long-lived object to reduce DBus traffic.
// Create a parameters object
// Set its attributes
"<b>%1</b> tweets received today");
"No tweets today");
"myapptextdomain");
// You can hold onto this shared object for as long as you want.
// It will be destroyed when the manager is destroyed.
metricManager, parameters);
// Remember to free the parameters object after use
// The update is sent when the update object is destroyed.
// Providing a blank username string will use the current
// user according to the USER environment variable.
metric, "username");
// The data is ordered starting from today, going backwards in time
// Delete and dispatch the metri update
// Free the manager when done with it
return 0;
}
USERMETRICSINPUT_EXPORT void usermetricsinput_metricparameters_set_format_string(UserMetricsInputMetricParameters metricParameter, const char *formatString)
Set the string to print in the output API, e.g. "<b>%1</b> messages received today".
USERMETRICSINPUT_EXPORT UserMetricsInputMetric usermetricsinput_metricmanager_add(UserMetricsInputMetricManager metricManager, UserMetricsInputMetricParameters metricParameters)
Register a new UserMetricsInputMetric.
USERMETRICSINPUT_EXPORT void usermetricsinput_metricparameters_delete(UserMetricsInputMetricParameters metricParameters)
Free a UserMetricsInputMetricParameters.
void * UserMetricsInputMetric
A single user metric, e.g. "number of e-mails today" or "photos taken today".
Definition usermetricsinput.h:57
void * UserMetricsInputMetricParameters
Parameters for constructing a metric.
Definition usermetricsinput.h:52
USERMETRICSINPUT_EXPORT UserMetricsInputMetricUpdate usermetricsinput_metric_update(UserMetricsInputMetric metric, const char *username)
Create an update to a particular metric.
USERMETRICSINPUT_EXPORT void usermetricsinput_metricmanager_delete(UserMetricsInputMetricManager metricManager)
Free a UserMetricsInputMetricManager.
void * UserMetricsInputMetricManager
A central place for registering user metrics.
Definition usermetricsinput.h:47
USERMETRICSINPUT_EXPORT void usermetricsinput_metricupdate_add_data(UserMetricsInputMetricUpdate metricUpdate, double data)
Add data to a UserMetricsInputMetricUpdate.
void * UserMetricsInputMetricUpdate
A update to a user metric for a particular user.
Definition usermetricsinput.h:62
USERMETRICSINPUT_EXPORT void usermetricsinput_metricupdate_delete(UserMetricsInputMetricUpdate metricUpdate)
Free a UserMetricsInputMetric.
USERMETRICSINPUT_EXPORT void usermetricsinput_metricparameters_set_text_domain(UserMetricsInputMetricParameters metricParameter, const char *textDomain)
Set the translation domain.
USERMETRICSINPUT_EXPORT void usermetricsinput_metricparameters_set_empty_data_string(UserMetricsInputMetricParameters metricParameter, const char *emptyDataString)
set the string to print in the case of no data, e.g. "No messages received today"
USERMETRICSINPUT_EXPORT UserMetricsInputMetricParameters usermetricsinput_metricparameters_new(const char *dataSourceId)
Construct a new UserMetricsInputMetricParameters.
USERMETRICSINPUT_EXPORT UserMetricsInputMetricManager usermetricsinput_metricmanager_new()
Construct a new UserMetricsInputMetricManager.