00001 #include "channel.h"
00002 #include "bchash.h"
00003 #include "filexml.h"
00004 #include <string.h>
00005
00006
00007
00008 Channel::Channel()
00009 {
00010 reset();
00011 }
00012
00013 Channel::Channel(Channel *channel)
00014 {
00015 reset();
00016 printf("Channel::Channel(Channel *channel) not supported\n");
00017 }
00018
00019 Channel::~Channel()
00020 {
00021 }
00022
00023
00024 void Channel::reset()
00025 {
00026
00027 use_frequency = 0;
00028 use_fine = 0;
00029 use_norm = 0;
00030 use_input = 0;
00031
00032 title[0] = 0;
00033 device_name[0] = 0;
00034 entry = 0;
00035 freqtable = 0;
00036 fine_tune = 0;
00037 input = 0;
00038 norm = 0;
00039 device_index = 0;
00040 tuner = 0;
00041 has_scanning = 0;
00042
00043 audio_pid = 0x14;
00044 video_pid = 0x11;
00045 }
00046
00047 void Channel::dump()
00048 {
00049 printf("Channel::dump title=%s\n"
00050 "use_freq=%d\n"
00051 "use_fine=%d\n"
00052 "use_norm=%d\n"
00053 "use_input=%d\n"
00054 "has_scanning=%d\n",
00055 title,
00056 use_frequency,
00057 use_fine,
00058 use_norm,
00059 use_input,
00060 has_scanning);
00061 }
00062
00063 Channel& Channel::operator=(Channel &channel)
00064 {
00065 printf("Channel::operator= is not supported.\n");
00066 return *this;
00067 }
00068
00069 void Channel::copy_settings(Channel *channel)
00070 {
00071 strcpy(this->title, channel->title);
00072 this->entry = channel->entry;
00073 this->freqtable = channel->freqtable;
00074 this->fine_tune = channel->fine_tune;
00075 this->input = channel->input;
00076 this->norm = channel->norm;
00077 this->device_index = channel->device_index;
00078 this->tuner = channel->tuner;
00079 this->audio_pid = channel->audio_pid;
00080 this->video_pid = channel->video_pid;
00081 }
00082
00083 void Channel::copy_usage(Channel *channel)
00084 {
00085 this->use_frequency = channel->use_frequency;
00086 this->use_fine = channel->use_fine;
00087 this->use_norm = channel->use_norm;
00088 this->use_input = channel->use_input;
00089 this->has_scanning = channel->has_scanning;
00090 }
00091
00092 int Channel::load(FileXML *file)
00093 {
00094 int done = 0;
00095 char *text;
00096
00097
00098 while(!done)
00099 {
00100 done = file->read_tag();
00101 if(!done)
00102 {
00103 if(file->tag.title_is("CHANNEL"))
00104 {
00105 entry = file->tag.get_property("ENTRY", entry);
00106 freqtable = file->tag.get_property("FREQTABLE", freqtable);
00107 fine_tune = file->tag.get_property("FINE_TUNE", fine_tune);
00108 input = file->tag.get_property("INPUT", input);
00109 norm = file->tag.get_property("NORM", norm);
00110 device_index = file->tag.get_property("DEVICE_INDEX", device_index);
00111 tuner = file->tag.get_property("TUNER", tuner);
00112 audio_pid = file->tag.get_property("AUDIO_PID", audio_pid);
00113 video_pid = file->tag.get_property("VIDEO_PID", video_pid);
00114 text = file->read_text();
00115 strcpy(title, text);
00116 }
00117 else
00118 if(file->tag.title_is("/CHANNEL"))
00119 return 0;
00120 }
00121 }
00122 return done;
00123 }
00124
00125 int Channel::save(FileXML *file)
00126 {
00127 file->tag.set_title("CHANNEL");
00128 file->tag.set_property("ENTRY", entry);
00129 file->tag.set_property("FREQTABLE", freqtable);
00130 file->tag.set_property("FINE_TUNE", fine_tune);
00131 file->tag.set_property("INPUT", input);
00132 file->tag.set_property("NORM", norm);
00133 file->tag.set_property("DEVICE_INDEX", device_index);
00134 file->tag.set_property("TUNER", tuner);
00135 file->tag.set_property("AUDIO_PID", audio_pid);
00136 file->tag.set_property("VIDEO_PID", video_pid);
00137 file->append_tag();
00138 file->append_text(title);
00139 file->tag.set_title("/CHANNEL");
00140 file->append_tag();
00141 file->append_newline();
00142 }
00143
00144
00145
00146 void Channel::load_defaults(BC_Hash *defaults)
00147 {
00148 freqtable = defaults->get("SCAN_FREQTABLE", freqtable);
00149 input = defaults->get("SCAN_INPUT", input);
00150 norm = defaults->get("SCAN_NORM", norm);
00151 }
00152
00153 void Channel::save_defaults(BC_Hash *defaults)
00154 {
00155 defaults->update("SCAN_FREQTABLE", freqtable);
00156 defaults->update("SCAN_INPUT", input);
00157 defaults->update("SCAN_NORM", norm);
00158 }
00159
00160