~ubuntu-branches/debian/jessie/pianobar/jessie

« back to all changes in this revision

Viewing changes to src/libpiano/response.c

  • Committer: Package Import Robot
  • Author(s): Luke Faraone, Unit 193, Luke Faraone
  • Date: 2014-08-17 11:46:41 UTC
  • mfrom: (1.3.12)
  • Revision ID: package-import@ubuntu.com-20140817114641-oyn9z8kfi5g99rvj
Tags: 2014.06.08-1
[ Unit 193 ]
* New upstream release.
* Drop build dependencies of libmad0-dev and libfaad-dev, switch to libav*
* Build against libjson-c-dev instead of libjson0-dev. Closes: #745009.
* Switch to dh7 from CDBS.
* Add pianobar-dbg package.
* Add multiarch support.
* Reduce exessive linking via --as-needed

[ Luke Faraone ]
* Add Unit 193 as uploader.
* Correct libpianobar symbol file to remove Debian revision.

Show diffs side-by-side

added added

removed removed

Lines of Context:
130
130
                        switch (reqData->step) {
131
131
                                case 0: {
132
132
                                        /* decrypt timestamp */
133
 
                                        const char *cryptedTimestamp = json_object_get_string (
 
133
                                        const char * const cryptedTimestamp = json_object_get_string (
134
134
                                                        json_object_object_get (result, "syncTime"));
135
 
                                        unsigned long timestamp = 0;
136
135
                                        const time_t realTimestamp = time (NULL);
137
136
                                        char *decryptedTimestamp = NULL;
138
137
                                        size_t decryptedSize;
142
141
                                                        cryptedTimestamp, &decryptedSize)) != NULL &&
143
142
                                                        decryptedSize > 4) {
144
143
                                                /* skip four bytes garbage(?) at beginning */
145
 
                                                timestamp = strtoul (decryptedTimestamp+4, NULL, 0);
146
 
                                                ph->timeOffset = realTimestamp - timestamp;
 
144
                                                const unsigned long timestamp = strtoul (
 
145
                                                                decryptedTimestamp+4, NULL, 0);
 
146
                                                ph->timeOffset = (long int) realTimestamp -
 
147
                                                                (long int) timestamp;
147
148
                                                ret = PIANO_RET_CONTINUE_REQUEST;
148
149
                                        }
149
150
                                        free (decryptedTimestamp);
177
178
                        json_object *stations = json_object_object_get (result,
178
179
                                        "stations"), *mix = NULL;
179
180
 
180
 
                        for (size_t i=0; i < json_object_array_length (stations); i++) {
 
181
                        for (int i = 0; i < json_object_array_length (stations); i++) {
181
182
                                PianoStation_t *tmpStation;
182
183
                                json_object *s = json_object_array_get_idx (stations, i);
183
184
 
200
201
                        if (mix != NULL) {
201
202
                                PianoStation_t *curStation = ph->stations;
202
203
                                PianoListForeachP (curStation) {
203
 
                                        for (size_t i = 0; i < json_object_array_length (mix); i++) {
 
204
                                        for (int i = 0; i < json_object_array_length (mix); i++) {
204
205
                                                json_object *id = json_object_array_get_idx (mix, i);
205
206
                                                if (strcmp (json_object_get_string (id),
206
207
                                                                curStation->id) == 0) {
224
225
                        json_object *items = json_object_object_get (result, "items");
225
226
                        assert (items != NULL);
226
227
 
227
 
                        for (size_t i=0; i < json_object_array_length (items); i++) {
 
228
                        for (int i = 0; i < json_object_array_length (items); i++) {
228
229
                                json_object *s = json_object_array_get_idx (items, i);
229
230
                                PianoSong_t *song;
230
231
 
277
278
                                song->detailUrl = PianoJsonStrdup (s, "songDetailUrl");
278
279
                                song->fileGain = json_object_get_double (
279
280
                                                json_object_object_get (s, "trackGain"));
 
281
                                song->length = json_object_get_int (
 
282
                                                json_object_object_get (s, "trackLength"));
280
283
                                switch (json_object_get_int (json_object_object_get (s,
281
284
                                                "songRating"))) {
282
285
                                        case 1:
342
345
                        /* get artists */
343
346
                        json_object *artists = json_object_object_get (result, "artists");
344
347
                        if (artists != NULL) {
345
 
                                for (size_t i=0; i < json_object_array_length (artists); i++) {
 
348
                                for (int i = 0; i < json_object_array_length (artists); i++) {
346
349
                                        json_object *a = json_object_array_get_idx (artists, i);
347
350
                                        PianoArtist_t *artist;
348
351
 
361
364
                        /* get songs */
362
365
                        json_object *songs = json_object_object_get (result, "songs");
363
366
                        if (songs != NULL) {
364
 
                                for (size_t i=0; i < json_object_array_length (songs); i++) {
 
367
                                for (int i = 0; i < json_object_array_length (songs); i++) {
365
368
                                        json_object *s = json_object_array_get_idx (songs, i);
366
369
                                        PianoSong_t *song;
367
370
 
415
418
                        /* get genre stations */
416
419
                        json_object *categories = json_object_object_get (result, "categories");
417
420
                        if (categories != NULL) {
418
 
                                for (size_t i = 0; i < json_object_array_length (categories); i++) {
 
421
                                for (int i = 0; i < json_object_array_length (categories); i++) {
419
422
                                        json_object *c = json_object_array_get_idx (categories, i);
420
423
                                        PianoGenreCategory_t *tmpGenreCategory;
421
424
 
431
434
                                        json_object *stations = json_object_object_get (c,
432
435
                                                        "stations");
433
436
                                        if (stations != NULL) {
434
 
                                                for (size_t k = 0;
 
437
                                                for (int k = 0;
435
438
                                                                k < json_object_array_length (stations); k++) {
436
439
                                                        json_object *s =
437
440
                                                                        json_object_array_get_idx (stations, k);
486
489
                                                sizeof (*reqData->retExplain));
487
490
                                strncpy (reqData->retExplain, "We're playing this track "
488
491
                                                "because it features ", strSize);
489
 
                                for (size_t i=0; i < json_object_array_length (explanations); i++) {
 
492
                                for (int i = 0; i < json_object_array_length (explanations); i++) {
490
493
                                        json_object *e = json_object_array_get_idx (explanations,
491
494
                                                        i);
492
495
                                        const char *s = json_object_get_string (
521
524
                                /* songs */
522
525
                                json_object *songs = json_object_object_get (music, "songs");
523
526
                                if (songs != NULL) {
524
 
                                        for (size_t i = 0; i < json_object_array_length (songs); i++) {
 
527
                                        for (int i = 0; i < json_object_array_length (songs); i++) {
525
528
                                                json_object *s = json_object_array_get_idx (songs, i);
526
529
                                                PianoSong_t *seedSong;
527
530
 
543
546
                                json_object *artists = json_object_object_get (music,
544
547
                                                "artists");
545
548
                                if (artists != NULL) {
546
 
                                        for (size_t i = 0; i < json_object_array_length (artists); i++) {
 
549
                                        for (int i = 0; i < json_object_array_length (artists); i++) {
547
550
                                                json_object *a = json_object_array_get_idx (artists, i);
548
551
                                                PianoArtist_t *seedArtist;
549
552
 
566
569
                                        "feedback");
567
570
                        if (feedback != NULL) {
568
571
                                json_object_object_foreach (feedback, key, val) {
569
 
                                        for (size_t i = 0; i < json_object_array_length (val); i++) {
 
572
                                        for (int i = 0; i < json_object_array_length (val); i++) {
570
573
                                                json_object *s = json_object_array_get_idx (val, i);
571
574
                                                PianoSong_t *feedbackSong;
572
575