00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00031
00032 #ifdef HAVE_CONFIG_H
00033 #include "autoconfig.h"
00034 #endif
00035
00036 #ifdef ONLINE_SERVICES
00037
00038 #include "online_service.h"
00039 #include "tools.h"
00040
00041 using namespace zmm;
00042 using namespace mxml;
00043
00044
00045
00046 char service_prefixes[] = { '\0', 'Y', 'S', 'W', 'T', '\0' };
00047
00048 OnlineServiceList::OnlineServiceList()
00049 {
00050 service_list = Ref<Array<OnlineService> > (new Array<OnlineService>(OS_Max));
00051 }
00052
00053 void OnlineServiceList::registerService(Ref<OnlineService> service)
00054 {
00055 if (service == nil)
00056 return;
00057
00058 if (service->getServiceType() >= OS_Max)
00059 {
00060 throw _Exception(_("Requested service with illegal type!"));
00061 }
00062
00063 service_list->set(service, service->getServiceType());
00064 }
00065
00066 Ref<OnlineService> OnlineServiceList::getService(service_type_t service)
00067 {
00068 if ((service > OS_Max) || (service < 0))
00069 return nil;
00070
00071 return service_list->get(service);
00072 }
00073
00074 OnlineService::OnlineService()
00075 {
00076 taskCount = 0;
00077 refresh_interval = 0;
00078 purge_interval = 0;
00079 }
00080
00081 char OnlineService::getStoragePrefix(service_type_t service)
00082 {
00083 if ((service < 0) || (service >= OS_Max))
00084 throw _Exception(_("Illegal service requested\n"));
00085
00086 return service_prefixes[service];
00087 }
00088
00089 char OnlineService::getStoragePrefix()
00090 {
00091 return getStoragePrefix(getServiceType());
00092 }
00093
00094 String OnlineService::getCheckAttr(Ref<Element> xml, String attrname)
00095 {
00096 String temp = xml->getAttribute(attrname);
00097 if (string_ok(temp))
00098 return temp;
00099 else
00100 throw _Exception(getServiceName() + _(": Tag <") + xml->getName() +
00101 _("> is missing the requred \"") + attrname +
00102 _("\" attribute!"));
00103 return nil;
00104 }
00105
00106 int OnlineService::getCheckPosIntAttr(Ref<Element> xml, String attrname)
00107 {
00108 int itmp;
00109 String temp = xml->getAttribute(attrname);
00110 if (string_ok(temp))
00111 itmp = temp.toInt();
00112 else
00113 throw _Exception(getServiceName() + _(": Tag <") + xml->getName() +
00114 _("> is missing the requred \"") + attrname +
00115 _("\" attribute!"));
00116
00117 if (itmp < 1)
00118 throw _Exception(_("Invalid value in ") + attrname + _(" for <") +
00119 xml->getName() + _("> tag"));
00120
00121 return itmp;
00122 }
00123
00124
00125 #endif//ONLINE_SERVICES