00001 #include "channel.h"
00002 #include "defaults.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
00044
00045 Channel& Channel::operator=(Channel &channel)
00046 {
00047 printf("Channel::operator= not supported.\n");
00048 return *this;
00049 }
00050
00051 void Channel::copy_settings(Channel *channel)
00052 {
00053 strcpy(this->title, channel->title);
00054 this->entry = channel->entry;
00055 this->freqtable = channel->freqtable;
00056 this->fine_tune = channel->fine_tune;
00057 this->input = channel->input;
00058 this->norm = channel->norm;
00059 this->device_index = channel->device_index;
00060 this->tuner = channel->tuner;
00061 }
00062
00063 void Channel::copy_usage(Channel *channel)
00064 {
00065 this->use_frequency = channel->use_frequency;
00066 this->use_fine = channel->use_fine;
00067 this->use_norm = channel->use_norm;
00068 this->use_input = channel->use_input;
00069 this->has_scanning = channel->has_scanning;
00070 }
00071
00072 int Channel::load(FileXML *file)
00073 {
00074 int done = 0;
00075 char *text;
00076
00077
00078 while(!done)
00079 {
00080 done = file->read_tag();
00081 if(!done)
00082 {
00083 if(file->tag.title_is("CHANNEL"))
00084 {
00085 entry = file->tag.get_property("ENTRY", entry);
00086 freqtable = file->tag.get_property("FREQTABLE", freqtable);
00087 fine_tune = file->tag.get_property("FINE_TUNE", fine_tune);
00088 input = file->tag.get_property("INPUT", input);
00089 norm = file->tag.get_property("NORM", norm);
00090 device_index = file->tag.get_property("DEVICE_INDEX", device_index);
00091 tuner = file->tag.get_property("TUNER", tuner);
00092 text = file->read_text();
00093 strcpy(title, text);
00094 }
00095 else
00096 if(file->tag.title_is("/CHANNEL"))
00097 return 0;
00098 }
00099 }
00100 return done;
00101 }
00102
00103 int Channel::save(FileXML *file)
00104 {
00105 file->tag.set_title("CHANNEL");
00106 file->tag.set_property("ENTRY", entry);
00107 file->tag.set_property("FREQTABLE", freqtable);
00108 file->tag.set_property("FINE_TUNE", fine_tune);
00109 file->tag.set_property("INPUT", input);
00110 file->tag.set_property("NORM", norm);
00111 file->tag.set_property("DEVICE_INDEX", device_index);
00112 file->tag.set_property("TUNER", tuner);
00113 file->append_tag();
00114 file->append_text(title);
00115 file->tag.set_title("/CHANNEL");
00116 file->append_tag();
00117 file->append_newline();
00118 }
00119
00120
00121
00122 void Channel::load_defaults(Defaults *defaults)
00123 {
00124 freqtable = defaults->get("SCAN_FREQTABLE", freqtable);
00125 input = defaults->get("SCAN_INPUT", input);
00126 norm = defaults->get("SCAN_NORM", norm);
00127 }
00128
00129 void Channel::save_defaults(Defaults *defaults)
00130 {
00131 defaults->update("SCAN_FREQTABLE", freqtable);
00132 defaults->update("SCAN_INPUT", input);
00133 defaults->update("SCAN_NORM", norm);
00134 }
00135
00136