~cjwatson/libusermetrics/valgrind-optional

« back to all changes in this revision

Viewing changes to examples/MetricManagerTodayCAPI.c

  • Committer: Pete Woods
  • Date: 2013-07-09 16:51:58 UTC
  • mto: This revision was merged to the branch mainline in revision 100.
  • Revision ID: pete.woods@canonical.com-20130709165158-rcym0f05hz714k29
Documentation

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <libusermetricsinput/usermetricsinput.h>
 
2
 
 
3
int main(int argc, char *argv[]) {
 
4
        // We start with a manager object
 
5
        UserMetricsInputMetricManager metricManager =
 
6
                        usermetricsinput_metricmanager_new();
 
7
 
 
8
        // You can hold onto this shared object for as long as you want
 
9
        UserMetricsInputMetric metric = usermetricsinput_metricmanager_add(
 
10
                        metricManager, "photo-app-photos", "<b>%1</b> photos taken today",
 
11
                        "No photos today", APP_ID);
 
12
 
 
13
        // The update is sent when the update object is destroyed.
 
14
        // Providing a blank username string will use the current
 
15
        // user according to the USER environment variable.
 
16
        usermetricsinput_metric_increment(metric, 1, "");
 
17
 
 
18
        // Now we're done with the manager
 
19
        usermetricsinput_metricmanager_delete(metricManager);
 
20
 
 
21
        return 0;
 
22
}
 
23