chiark / gitweb /
Switch to GPL v3
[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 3 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,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU 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, see <http://www.gnu.org/licenses/>.
17  */
18
19 #include "common.h"
20
21 #include <stddef.h>
22 #include <stdlib.h>
23 #include <time.h>
24
25 #include <disorder.h>
26
27 static void record(const char *track, const char *what) {
28   const char *count;
29   int ncount;
30   char buf[64];
31
32   if((count = disorder_track_get_data(track, what)))
33     ncount = atoi(count);
34   else
35     ncount = 0;
36   disorder_snprintf(buf, sizeof buf, "%d", ncount + 1);
37   disorder_track_set_data(track, what, buf);
38 }
39
40 void disorder_notify_play(const char *track,
41                           const char *submitter) {
42   char buf[64];
43   
44   if(submitter)
45     record(track, "requested");
46   record(track, "played");
47   disorder_snprintf(buf, sizeof buf, "%"PRIdMAX, (intmax_t)time(0));
48   disorder_track_set_data(track, "played_time", buf);
49 }
50
51 void disorder_notify_queue(const char attribute((unused)) *track,
52                            const char attribute((unused)) *submitter) {
53 }
54
55 void disorder_notify_scratch(const char *track,
56                              const char attribute((unused)) *submitter,
57                              const char attribute((unused)) *scratcher,
58                              int attribute((unused)) seconds) {
59   record(track, "scratched");
60 }
61
62 void disorder_notify_not_scratched(const char *track,
63                                    const char attribute((unused)) *submitter) {
64   record(track, "unscratched");
65 }
66
67 void disorder_notify_queue_remove(const char attribute((unused)) *track,
68                                   const char attribute((unused)) *remover) {
69 }
70
71 void disorder_notify_queue_move(const char attribute((unused)) *track,
72                                 const char attribute((unused)) *mover) {
73 }
74
75 void disorder_notify_pause(const char attribute((unused)) *track,
76                            const char attribute((unused)) *who) {
77 }
78
79 void disorder_notify_resume(const char attribute((unused)) *track,
80                             const char attribute((unused)) *who) {
81 }
82
83 /*
84 Local Variables:
85 c-basic-offset:2
86 comment-column:40
87 End:
88 */