chiark / gitweb /
The Debian install scripts now uses the current locale's encoding as
[disorder] / plugins / notify.c
1 /*
2  * This file is part of DisOrder.
3  * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA
19  */
20
21 #include <config.h>
22 #include "types.h"
23
24 #include <stddef.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <time.h>
28
29 #include <disorder.h>
30
31 static void record(const char *track, const char *what) {
32   const char *count;
33   int ncount;
34   char buf[64];
35
36   if((count = disorder_track_get_data(track, what)))
37     ncount = atoi(count);
38   else
39     ncount = 0;
40   disorder_snprintf(buf, sizeof buf, "%d", ncount + 1);
41   disorder_track_set_data(track, what, buf);
42 }
43
44 void disorder_notify_play(const char *track,
45                           const char *submitter) {
46   char buf[64];
47   
48   if(submitter)
49     record(track, "requested");
50   record(track, "played");
51   disorder_snprintf(buf, sizeof buf, "%"PRIdMAX, (intmax_t)time(0));
52   disorder_track_set_data(track, "played_time", buf);
53 }
54
55 void disorder_notify_queue(const char attribute((unused)) *track,
56                            const char attribute((unused)) *submitter) {
57 }
58
59 void disorder_notify_scratch(const char *track,
60                              const char attribute((unused)) *submitter,
61                              const char attribute((unused)) *scratcher,
62                              int attribute((unused)) seconds) {
63   record(track, "scratched");
64 }
65
66 void disorder_notify_not_scratched(const char *track,
67                                    const char attribute((unused)) *submitter) {
68   record(track, "unscratched");
69 }
70
71 void disorder_notify_queue_remove(const char attribute((unused)) *track,
72                                   const char attribute((unused)) *remover) {
73 }
74
75 void disorder_notify_queue_move(const char attribute((unused)) *track,
76                                 const char attribute((unused)) *mover) {
77 }
78
79 void disorder_notify_pause(const char attribute((unused)) *track,
80                            const char attribute((unused)) *who) {
81 }
82
83 void disorder_notify_resume(const char attribute((unused)) *track,
84                             const char attribute((unused)) *who) {
85 }
86
87 /*
88 Local Variables:
89 c-basic-offset:2
90 comment-column:40
91 End:
92 */