Project

General

Profile

Patch for setting EPG default charset ยป epg_default_charset.patch

Martin Mrvka, 2011-03-13 14:12

View differences:

src/channels.c
285 285
      }
286 286
    }
287 287
  }
288

  
289
  tvh_str_update(&ch->ch_epg_default_charset, htsmsg_get_str(c, "epg_default_charset"));
290

  
288 291
}
289 292

  
290 293

  
......
338 341
  htsmsg_add_u32(m, "dvr_extra_time_post", ch->ch_dvr_extra_time_post);
339 342
  htsmsg_add_s32(m, "channel_number", ch->ch_number);
340 343

  
344
  if(ch->ch_epg_default_charset != NULL)
345
    htsmsg_add_str(m, "epg_default_charset", ch->ch_epg_default_charset);
346

  
341 347
  hts_settings_save(m, "channels/%d", ch->ch_id);
342 348
  htsmsg_destroy(m);
343 349
}
......
413 419
  free(ch->ch_name);
414 420
  free(ch->ch_sname);
415 421
  free(ch->ch_icon);
422
  free(ch->ch_epg_default_charset);
416 423

  
417 424
  channel_list_changed();
418 425
  
......
587 594
    channel_save(ch);
588 595
}
589 596

  
597
/**
598
 *
599
 */
600
void
601
channel_set_epg_default_charset(channel_t *ch, const char *epg_default_charset)
602
{
603
  lock_assert(&global_lock);
604

  
605
  if(ch->ch_epg_default_charset != NULL && !strcmp(ch->ch_epg_default_charset, epg_default_charset))
606
    return;
607

  
608
  free(ch->ch_epg_default_charset);
609
  ch->ch_epg_default_charset = strdup(epg_default_charset);
610
  channel_save(ch);
611
  htsp_channel_update(ch);
612
}
590 613

  
591 614

  
592 615

  
src/channels.h
63 63

  
64 64
  struct channel_tag_mapping_list ch_ctms;
65 65

  
66
  /**
67
   * EPG default charset
68
   */
69
  char *ch_epg_default_charset;
70

  
66 71
} channel_t;
67 72

  
68 73

  
......
127 132

  
128 133
void channel_set_tags_from_list(channel_t *ch, const char *maplist);
129 134

  
135
void channel_set_epg_default_charset(channel_t *ch, const char *epg_default_charset);
136

  
130 137
channel_tag_t *channel_tag_find_by_name(const char *name, int create);
131 138

  
132 139
channel_tag_t *channel_tag_find_by_identifier(uint32_t id);
src/dvb/dvb_support.c
74 74
 */
75 75

  
76 76
int
77
dvb_get_string(char *dst, size_t dstlen, const uint8_t *src, size_t srclen)
77
dvb_get_string(char *dst, size_t dstlen, const uint8_t *src, size_t srclen, char *epg_default_charset)
78 78
{
79 79
  iconv_t ic;
80 80
  int len;
......
121 121
    return -1;
122 122

  
123 123
  default:
124
    ic = convert_latin1;
124
    if (epg_default_charset != NULL && sscanf(epg_default_charset, "ISO8859-%d", &i) > 0) {
125
      if (i > 0 && i < 16) {
126
        ic = convert_iso_8859[i];
127
      } else {
128
        ic = convert_latin1;
129
      }
130
    } else {
131
      ic = convert_latin1;
132
    }
125 133
    break;
126 134
  }
127 135

  
......
175 183

  
176 184
int
177 185
dvb_get_string_with_len(char *dst, size_t dstlen, 
178
			const uint8_t *buf, size_t buflen)
186
			const uint8_t *buf, size_t buflen, char *epg_default_charset)
179 187
{
180 188
  int l = buf[0];
181 189

  
182 190
  if(l + 1 > buflen)
183 191
    return -1;
184 192

  
185
  if(dvb_get_string(dst, dstlen, buf + 1, l))
193
  if(dvb_get_string(dst, dstlen, buf + 1, l, epg_default_charset))
186 194
    return -1;
187 195

  
188 196
  return l + 1;
src/dvb/dvb_support.h
51 51
#define DVB_DESC_LOCAL_CHAN   0x83
52 52

  
53 53
int dvb_get_string(char *dst, size_t dstlen, const uint8_t *src, 
54
		   const size_t srclen);
54
		   const size_t srclen, char *epg_default_charset);
55 55

  
56 56
int dvb_get_string_with_len(char *dst, size_t dstlen, 
57
			    const uint8_t *buf, size_t buflen);
57
			    const uint8_t *buf, size_t buflen, char *epg_default_charset);
58 58

  
59 59
#define bcdtoint(i) ((((i & 0xf0) >> 4) * 10) + (i & 0x0f))
60 60

  
src/dvb/dvb_tables.c
369 369
static int
370 370
dvb_desc_short_event(uint8_t *ptr, int len, 
371 371
		     char *title, size_t titlelen,
372
		     char *desc,  size_t desclen)
372
		     char *desc,  size_t desclen,
373
                     char *epg_default_charset)
373 374
{
374 375
  int r;
375 376

  
......
377 378
    return -1;
378 379
  ptr += 3; len -= 3;
379 380

  
380
  if((r = dvb_get_string_with_len(title, titlelen, ptr, len)) < 0)
381
  if((r = dvb_get_string_with_len(title, titlelen, ptr, len, epg_default_charset)) < 0)
381 382
    return -1;
382 383
  ptr += r; len -= r;
383 384

  
384
  if((r = dvb_get_string_with_len(desc, desclen, ptr, len)) < 0)
385
  if((r = dvb_get_string_with_len(desc, desclen, ptr, len, epg_default_charset)) < 0)
385 386
    return -1;
386 387

  
387 388
  return 0;
......
394 395
dvb_desc_extended_event(uint8_t *ptr, int len, 
395 396
		     char *desc, size_t desclen,
396 397
		     char *item, size_t itemlen,
397
                     char *text, size_t textlen)
398
                     char *text, size_t textlen,
399
                     char *epg_default_charset)
398 400
{
399 401
  int count = ptr[4], r;
400 402
  uint8_t *localptr = ptr + 5, *items = localptr; 
......
434 436
  count = localptr[0];
435 437

  
436 438
  /* get text */
437
  if((r = dvb_get_string_with_len(text, textlen, localptr, locallen)) < 0)
439
  if((r = dvb_get_string_with_len(text, textlen, localptr, locallen, epg_default_charset)) < 0)
438 440
    return -1;
439 441

  
440 442
  return 0;
......
459 461
  ptr++;
460 462
  len--;
461 463

  
462
  if((r = dvb_get_string_with_len(provider, providerlen, ptr, len)) < 0)
464
  if((r = dvb_get_string_with_len(provider, providerlen, ptr, len, NULL)) < 0)
463 465
    return -1;
464 466
  ptr += r; len -= r;
465 467

  
466
  if((r = dvb_get_string_with_len(name, namelen, ptr, len)) < 0)
468
  if((r = dvb_get_string_with_len(name, namelen, ptr, len, NULL)) < 0)
467 469
    return -1;
468 470
  ptr += r; len -= r;
469 471
  return 0;
......
586 588
      case DVB_DESC_SHORT_EVENT:
587 589
	if(!dvb_desc_short_event(ptr, dlen,
588 590
				 title, sizeof(title),
589
				 desc,  sizeof(desc))) {
591
				 desc,  sizeof(desc),
592
                                 e->e_channel->ch_epg_default_charset)) {
590 593
	  changed |= epg_event_set_title(e, title);
591 594
	  changed |= epg_event_set_desc(e, desc);
592 595
	}
......
602 605
        if(!dvb_desc_extended_event(ptr, dlen,
603 606
              extdesc, sizeof(extdesc),
604 607
              extitem, sizeof(extitem),
605
              exttext, sizeof(exttext))) {
608
              exttext, sizeof(exttext),
609
              e->e_channel->ch_epg_default_charset)) {
606 610
          
607 611
          char language[4];
608 612
          memcpy(language, &ptr[1], 3);
......
1122 1126

  
1123 1127
    switch(tag) {
1124 1128
    case DVB_DESC_NETWORK_NAME:
1125
      if(dvb_get_string(networkname, sizeof(networkname), ptr, tlen))
1129
      if(dvb_get_string(networkname, sizeof(networkname), ptr, tlen, NULL))
1126 1130
	return -1;
1127 1131

  
1128 1132
      if(strcmp(tdmi->tdmi_network ?: "", networkname))
src/webui/extjs.c
342 342

  
343 343
    if((s = htsmsg_get_str(c, "number")) != NULL)
344 344
      channel_set_number(ch, atoi(s));
345

  
346
    if((s = htsmsg_get_str(c, "epg_default_charset")) != NULL)
347
      channel_set_epg_default_charset(ch, s);
348

  
345 349
  }
346 350
}
347 351

  
......
395 399
      htsmsg_add_s32(c, "epg_post_end",  ch->ch_dvr_extra_time_post);
396 400
      htsmsg_add_s32(c, "number",        ch->ch_number);
397 401

  
402
      if(ch->ch_epg_default_charset != NULL)
403
        htsmsg_add_str(c, "epg_default_charset", ch->ch_epg_default_charset);
404

  
398 405
      htsmsg_add_msg(array, NULL, c);
399 406
    }
400 407
    
src/webui/static/app/chconf.js
28 28
    autoLoad: true,
29 29
    root:'entries',
30 30
    fields: ['name', 'chid', 'xmltvsrc', 'tags', 'ch_icon',
31
	     'epg_pre_start', 'epg_post_end', 'number'],
31
	     'epg_pre_start', 'epg_post_end', 'number', 'epg_default_charset'],
32 32
    id: 'chid',
33 33
    url: "channels",
34 34
    baseParams: {
......
112 112
	}
113 113
    });
114 114

  
115
    var EPGCharsets = new Ext.data.SimpleStore({
116
	fields: ['key','value'],
117
	data: [
118
		['ISO6937','default'],
119
		['ISO6937','ISO6937'],
120
		['ISO8859-1','ISO8859-1'],
121
		['ISO8859-2','ISO8859-2'],
122
		['ISO8859-3','ISO8859-3'],
123
		['ISO8859-4','ISO8859-4'],
124
		['ISO8859-5','ISO8859-5'],
125
		['ISO8859-6','ISO8859-6'],
126
		['ISO8859-7','ISO8859-7'],
127
		['ISO8859-8','ISO8859-8'],
128
		['ISO8859-9','ISO8859-9'],
129
		['ISO8859-10','ISO8859-10'],
130
		['ISO8859-11','ISO8859-11'],
131
		['ISO8859-12','ISO8859-12'],
132
		['ISO8859-13','ISO8859-13'],
133
		['ISO8859-14','ISO8859-14'],
134
		['ISO8859-15','ISO8859-15']
135
	]
136
    });
115 137

  
116 138
    var fm = Ext.form;
117 139

  
......
250 272
	    minValue: 0,
251 273
	    maxValue: 1440
252 274
	})
253
    }, actions
275
    },
276
	{
277
		header: "EPG Default Charset",
278
		dataIndex: 'epg_default_charset',
279
		width: 200,
280
		renderer: function(value, metadata, record, row, col, store) {
281
			if (!value) {
282
				return '<span class="tvh-grid-unset">ISO6937</span>';
283
			} else {
284
				return value;
285
			}
286
		},
287
		editor: new fm.ComboBox({
288
			mode: 'local',
289
                	store: EPGCharsets,
290
			typeAhead: true,
291
			lazyRender: true,
292
			triggerAction: 'all',
293
			displayField:'value',
294
			valueField:'key'
295
		})
296
	},
297
	actions
254 298
    ]);
255 299

  
256 300

  
    (1-1/1)