void CBouquetManager::parseBouquetsXml(const xmlNodePtr root, bool bUser) { xmlNodePtr search=root->xmlChildrenNode; xmlNodePtr channel_node; if (search) { t_original_network_id original_network_id; t_service_id service_id; t_transport_stream_id transport_stream_id; int16_t satellitePosition; freq_id_t freq = 0; INFO("reading bouquets"); while ((search = xmlGetNextOccurence(search, "Bouquet")) != NULL) { char * name = xmlGetAttribute(search, (char *) "name"); //CZapitBouquet* newBouquet = addBouquet(xmlGetAttribute(search, (char *) "name"), bUser); CZapitBouquet* newBouquet = addBouquet(name, bUser); char* hidden = xmlGetAttribute(search, (char *) "hidden"); char* locked = xmlGetAttribute(search, (char *) "locked"); newBouquet->bHidden = hidden ? (strcmp(hidden, "1") == 0) : false; newBouquet->bLocked = locked ? (strcmp(locked, "1") == 0) : false; newBouquet->bFav = (strcmp(name, "favorites") == 0); channel_node = search->xmlChildrenNode; while ((channel_node = xmlGetNextOccurence(channel_node, "S")) != NULL) { std::string name = xmlGetAttribute(channel_node, (char *) "n"); GET_ATTR(channel_node, (char *) "i", SCANF_SERVICE_ID_TYPE, service_id); GET_ATTR(channel_node, (char *) "on", SCANF_ORIGINAL_NETWORK_ID_TYPE, original_network_id); GET_ATTR(channel_node, (char *) "s", SCANF_SATELLITE_POSITION_TYPE, satellitePosition); GET_ATTR(channel_node, (char *) "t", SCANF_TRANSPORT_STREAM_ID_TYPE, transport_stream_id); GET_ATTR(channel_node, (char *) "frq", SCANF_SATELLITE_POSITION_TYPE, freq); if(freq > 20000) freq = freq/1000; CZapitChannel* chan; chan = findChannelByChannelID(CREATE_CHANNEL_ID64); //printf("Bouquet Channel-ID freq %d pos %d id %llx\n", freq, satellitePosition, CREATE_CHANNEL_ID64); if (chan != NULL) { //printf("found\n"); DBG("%04x %04x %04x %s\n", transport_stream_id, original_network_id, service_id, xmlGetAttribute(channel_node, (char *) "n")); #if 0 if(bUser && (name.length() > 1)) chan->setName(name); #endif if(!bUser) chan->pname = (char *) newBouquet->Name.c_str(); chan->bAlwaysLocked = newBouquet->bLocked; newBouquet->addService(chan); } channel_node = channel_node->xmlNextNode; } if(!bUser) newBouquet->sortBouquet(); search = search->xmlNextNode; } INFO("found %d bouquets", Bouquets.size()); } }
/* ClientFlagsToggle {{{ */ static VALUE ClientFlagsToggle(VALUE self, char *type, int flag) { int iflags = 0; VALUE win = Qnil, flags = Qnil; SubMessageData data = { { 0, 0, 0, 0, 0 } }; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@win", win); GET_ATTR(self, "@flags", flags); subextSubtlextConnect(NULL); ///< Implicit open connection /* Update flags */ iflags = FIX2INT(flags); if(iflags & flag) iflags &= ~flag; else iflags |= flag; rb_iv_set(self, "@flags", INT2FIX(iflags)); /* Send message */ data.l[0] = XInternAtom(display, "_NET_WM_STATE_TOGGLE", False); data.l[1] = XInternAtom(display, type, False); subSharedMessage(display, NUM2LONG(win), "_NET_WM_STATE", data, 32, True); return self; } /* }}} */
VALUE subSubletUpdate(VALUE self) { int id = -1; VALUE name = Qnil; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@name", name); /* Check results */ if(-1 != ((id = subSubtlextFindString("SUBTLE_SUBLET_LIST", RSTRING_PTR(name), NULL, SUB_MATCH_EXACT)))) { SubMessageData data = { { 0, 0, 0, 0, 0 } }; /* Send message */ data.l[0] = id; subSharedMessage(display, DefaultRootWindow(display), "SUBTLE_SUBLET_UPDATE", data, 32, True); } else rb_raise(rb_eStandardError, "Failed finding sublet"); return Qnil; } /* }}} */
VALUE subextViewIcon(VALUE self) { unsigned long nicons = 0; VALUE id = Qnil, ret = Qnil; unsigned long *icons = NULL; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@id", id); subextSubtlextConnect(NULL); ///< Implicit open connection /* Check results */ if((icons = (unsigned long *)subSharedPropertyGet(display, DefaultRootWindow(display), XA_CARDINAL, XInternAtom(display, "SUBTLE_VIEW_ICONS", False), &nicons))) { int iid = FIX2INT(id); /* Check if id is in range and icon available */ if(0 <= iid && iid < nicons && -1 != icons[iid]) { /* Create new icon */ ret = rb_funcall(rb_const_get(mod, rb_intern("Icon")), rb_intern("new"), 1, LONG2NUM(icons[iid])); } free(icons); } return ret; } /* }}} */
VALUE subextSubletSend(VALUE self, VALUE value) { VALUE id = Qnil; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@id", id); /* Check object type */ if(T_STRING == rb_type(value)) { char *list = NULL; SubMessageData data = { { 0, 0, 0, 0, 0 } }; /* Store data */ list = strdup(RSTRING_PTR(value)); subSharedPropertySetStrings(display, DefaultRootWindow(display), XInternAtom(display, "SUBTLE_DATA", False), &list, 1); free(list); data.l[0] = FIX2INT(id); subSharedMessage(display, DefaultRootWindow(display), "SUBTLE_SUBLET_DATA", data, 32, True); } else rb_raise(rb_eArgError, "Unexpected value-type `%s'", rb_obj_classname(value)); return self; } /* }}} */
VALUE subColorToHex(VALUE self) { char buf[8] = { 0 }; VALUE red = Qnil, green = Qnil, blue = Qnil; /* Check ruby object */ GET_ATTR(self, "@red", red); GET_ATTR(self, "@green", green); GET_ATTR(self, "@blue", blue); snprintf(buf, sizeof(buf), "#%02X%02X%02X", (int)FIX2INT(red), (int)FIX2INT(green), (int)FIX2INT(blue)); return rb_str_new2(buf); } /* }}} */
VALUE subextViewUpdate(VALUE self) { long *tags = NULL, ntags = 0; VALUE id = Qnil; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@id", id); subextSubtlextConnect(NULL); ///< Implicit open connection /* Fetch tags */ if((tags = (long *)subSharedPropertyGet(display, ROOT, XA_CARDINAL, XInternAtom(display, "SUBTLE_VIEW_TAGS", False), (unsigned long *)&ntags))) { int idx = FIX2INT(id); rb_iv_set(self, "@tags", LONG2NUM(idx < ntags ? tags[idx] : 0)); free(tags); } return self; } /* }}} */
VALUE subSubletGeometryReader(VALUE self) { int nwins = 0, wx = 0, wy = 0, px = 0, py = 0; unsigned int wwidth = 0, wheight = 0, wbw = 0, wdepth = 0; unsigned int pwidth = 0, pheight = 0, pbw = 0, pdepth = 0; Window *wins = NULL, win = None, parent = None, wroot = None, proot = None; VALUE id = Qnil; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@id", id); /* Fetch data */ if((wins = subSubtlextWindowList("SUBTLE_SUBLET_WINDOWS", &nwins))) { win = wins[id]; free(wins); } /* Get parent and geometries */ XGetGeometry(display, win, &wroot, &wx, &wy, &wwidth, &wheight, &wbw, &wdepth); XQueryTree(display, win, &wroot, &parent, &wins, (unsigned int *)&nwins); ///< Get parent XGetGeometry(display, parent, &proot, &px, &py, &pwidth, &pheight, &pbw, &pdepth); if(wins) XFree(wins); return subGeometryInstantiate(px + wx, py + wy, wwidth, wheight); } /* }}} */
void CBouquetManager::makeBouquetfromCurrentservices(const xmlNodePtr root) { xmlNodePtr provider = root->xmlChildrenNode; // TODO: use locales CBouquet* newBouquet = addBouquet("Neue Sender"); newBouquet->bHidden = false; newBouquet->bLocked = false; t_original_network_id original_network_id; t_service_id service_id; t_transport_stream_id transport_stream_id; t_satellite_position satellitePosition; while (provider) { xmlNodePtr transponder = provider->xmlChildrenNode; while (xmlGetNextOccurence(transponder, "transponder") != NULL) { xmlNodePtr channel_node = transponder->xmlChildrenNode; while (xmlGetNextOccurence(channel_node, "channel") != NULL) { if (strncmp(xmlGetAttribute(channel_node, "action"), "remove", 6)) { GET_ATTR(provider, "position", SCANF_SATELLITE_POSITION_TYPE, satellitePosition); GET_ATTR(transponder, "onid", SCANF_ORIGINAL_NETWORK_ID_TYPE, original_network_id); GET_ATTR(transponder, "id", SCANF_TRANSPORT_STREAM_ID_TYPE, transport_stream_id); GET_ATTR(channel_node, "service_id", SCANF_SERVICE_ID_TYPE, service_id); CZapitChannel* chan = findChannelByChannelID(CREATE_CHANNEL_ID); if (chan != NULL) newBouquet->addService(chan); } channel_node = channel_node->xmlNextNode; } transponder = transponder->xmlNextNode; } provider = provider->xmlNextNode; } }
VALUE subextViewToString(VALUE self) { VALUE name = Qnil; /* Check ruby object */ GET_ATTR(self, "@name", name); return name; } /* }}} */
VALUE subGravityToSym(VALUE self) { VALUE name = Qnil; /* Check ruby object */ GET_ATTR(self, "@name", name); return CHAR2SYM(RSTRING_PTR(name)); } /* }}} */
void _bam_check_template_list(SEXP template_list) { if (!IS_LIST(template_list) || LENGTH(template_list) != N_TMPL_ELTS) Rf_error("'template' must be list(%d)", N_TMPL_ELTS); SEXP names = GET_ATTR(template_list, R_NamesSymbol); if (!IS_CHARACTER(names) || LENGTH(names) != N_TMPL_ELTS) Rf_error("'names(template)' must be character(%d)", N_TMPL_ELTS); for (int i = 0; i < LENGTH(names); ++i) if (strcmp(TMPL_ELT_NMS[i], CHAR(STRING_ELT(names, i))) != 0) Rf_error("'template' names do not match scan_bam_template\n'"); }
VALUE subColorToArray(VALUE self) { VALUE ary = Qnil, red = Qnil, green = Qnil, blue = Qnil; /* Check ruby object */ GET_ATTR(self, "@red", red); GET_ATTR(self, "@green", green); GET_ATTR(self, "@blue", blue); /* Create new array */ ary = rb_ary_new2(3); /* Set values */ rb_ary_push(ary, red); rb_ary_push(ary, green); rb_ary_push(ary, blue); return ary; } /* }}} */
VALUE subSubletDataReader(VALUE self) { VALUE id = Qnil; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@id", id); return id; } /* }}} */
static rc_t CC NodeDataReadAttribs(NodeData* data, const KXMLNode* node, const char* parentName, uint32_t idx) { rc_t rc = 0; assert(node && parentName && data); if (DEBUG_PRINT) OUTMSG(("<%s ", data->nodeName)); GET_ATTR(node, id); GET_ATTR(node, path); GET_ATTR(node, name); GET_ATTR(node, mtime); GET_ATTR(node, filetype); GET_ATTR(node, md5); GET_ATTR(node, crc32); READ_ATTR(node, size); READ_ATTR(node, offset); if (rc == 0) { /* TODO: what size is negative no error is detected */ char * attr = "size"; rc = KXMLNodeReadAttrAsU64(node, attr, &data->iSize); if (rc != 0) { if (GetRCState(rc) == rcNotFound) { rc = 0; } } attr = "offset"; rc = KXMLNodeReadAttrAsU64(node, attr, &data->iOffset); if (rc != 0) { if (GetRCState(rc) == rcNotFound) { rc = 0; } } /* else if (data->nodeName) { PLOGERR(klogErr, (klogErr, rc, "while calling KXMLNodeReadAttrAsU64($(name)/@$(attr))", "name=%s,attr=%s", data->nodeName, attr)); }*/ if (DEBUG_PRINT) { OUTMSG(("%s=\"%lu\" ", attr, data->iSize)); OUTMSG(("%s=\"%lu\" ", attr, data->iOffset)); } } if (DEBUG_PRINT) OUTMSG((">")); if (DEBUG_PRINT && data->nodeValue) OUTMSG(("%s", data->nodeValue)); if (DEBUG_PRINT) OUTMSG(("</%s>\n", data->nodeName)); return rc; }
VALUE subColorToHash(VALUE self) { VALUE klass = Qnil, hash = Qnil, red = Qnil, green = Qnil, blue = Qnil; /* Check ruby object */ GET_ATTR(self, "@red", red); GET_ATTR(self, "@green", green); GET_ATTR(self, "@blue", blue); /* Create new hash */ klass = rb_const_get(rb_mKernel, rb_intern("Hash")); hash = rb_funcall(klass, rb_intern("new"), 0, NULL); /* Set values */ rb_hash_aset(hash, CHAR2SYM("red"), red); rb_hash_aset(hash, CHAR2SYM("green"), green); rb_hash_aset(hash, CHAR2SYM("blue"), blue); return hash; } /* }}} */
/* ColorEqual {{{ */ VALUE ColorEqual(VALUE self, VALUE other, int check_type) { int ret = False; VALUE pixel1 = Qnil, pixel2 = Qnil; /* Check ruby object */ GET_ATTR(self, "@pixel", pixel1); GET_ATTR(other, "@pixel", pixel2); /* Check ruby object types */ if(check_type) { ret = (rb_obj_class(self) == rb_obj_class(other) && pixel1 == pixel2); } else ret = (pixel1 == pixel2); return ret ? Qtrue : Qfalse; } /* }}} */
VALUE subColorToString(VALUE self) { char buf[20] = { 0 }; VALUE pixel = Qnil; /* Check ruby object */ GET_ATTR(self, "@pixel", pixel); snprintf(buf, sizeof(buf), "%s#%ld%s", SEPARATOR, NUM2LONG(pixel), SEPARATOR); return rb_str_new2(buf); } /* }}} */
VALUE subGravityClients(VALUE self) { int i, nclients = 0; Window *clients = NULL; VALUE id = Qnil, klass = Qnil, meth = Qnil, array = Qnil, c = Qnil; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@id", id); subSubtlextConnect(NULL); ///< Implicit open connection /* Fetch data */ klass = rb_const_get(mod, rb_intern("Client")); meth = rb_intern("new"); array = rb_ary_new(); clients = subSubtlextWindowList("_NET_CLIENT_LIST", &nclients); /* Check results */ if(clients) { for(i = 0; i < nclients; i++) { unsigned long *gravity = NULL; /* Get window gravity */ gravity = (unsigned long *)subSharedPropertyGet(display, clients[i], XA_CARDINAL, XInternAtom(display, "SUBTLE_CLIENT_GRAVITY", False), NULL); /* Check if there are common tags or window is stick */ if(gravity && FIX2INT(id) == *gravity && !NIL_P(c = rb_funcall(klass, meth, 1, INT2FIX(i)))) { rb_iv_set(c, "@win", LONG2NUM(clients[i])); subClientUpdate(c); rb_ary_push(array, c); } if(gravity) free(gravity); } free(clients); } return array; } /* }}} */
/* ClientFlagsGet {{{ */ static VALUE ClientFlagsGet(VALUE self, int flag) { VALUE flags = Qnil; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@flags", flags) flags = rb_iv_get(self, "@flags"); return (FIXNUM_P(flags) && FIX2INT(flags) & flag) ? Qtrue : Qfalse; } /* }}} */
/* ClientFlagsSet {{{ */ static VALUE ClientFlagsSet(VALUE self, int flag, int toggle) { int iflags = flag; VALUE win = Qnil; SubMessageData data = { { 0, 0, 0, 0, 0 } }; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@win", win); /* Toggle flags */ if(toggle) { VALUE flags = Qnil; GET_ATTR(self, "@flags", flags); iflags = FIX2INT(flags); if(iflags & flag) iflags &= ~flag; else iflags |= flag; } /* Assemble message */ data.l[0] = NUM2LONG(win); data.l[1] = iflags; subSharedMessage(display, DefaultRootWindow(display), "SUBTLE_CLIENT_FLAGS", data, 32, True); rb_iv_set(self, "@flags", INT2FIX(iflags)); return self; } /* }}} */
VALUE subextViewSave(VALUE self) { int id = -1; VALUE name = Qnil; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@name", name); subextSubtlextConnect(NULL); ///< Implicit open connection /* Create view if needed */ if(-1 == (id = subextSubtlextFindString("_NET_DESKTOP_NAMES", RSTRING_PTR(name), NULL, SUB_MATCH_EXACT))) { SubMessageData data = { { 0, 0, 0, 0, 0 } }; snprintf(data.b, sizeof(data.b), "%s", RSTRING_PTR(name)); subSharedMessage(display, DefaultRootWindow(display), "SUBTLE_VIEW_NEW", data, 8, True); id = subextSubtlextFindString("_NET_DESKTOP_NAMES", RSTRING_PTR(name), NULL, SUB_MATCH_EXACT); } /* Guess view id */ if(-1 == id) { int nnames = 0; char **names = NULL; /* Get names of views */ if((names = subSharedPropertyGetStrings(display, DefaultRootWindow(display), XInternAtom(display, "_NET_DESKTOP_NAMES", False), &nnames))) { id = nnames; ///< New id should be last if(names) XFreeStringList(names); } } /* Set properties */ rb_iv_set(self, "@id", INT2FIX(id)); return self; } /* }}} */
VALUE subextSubletUpdate(VALUE self) { VALUE id = Qnil; SubMessageData data = { { 0, 0, 0, 0, 0 } }; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@id", id); /* Send message */ data.l[0] = FIX2INT(id); subSharedMessage(display, DefaultRootWindow(display), "SUBTLE_SUBLET_UPDATE", data, 32, True); return self; } /* }}} */
VALUE subextSubletVisibilityHide(VALUE self) { VALUE id = Qnil; SubMessageData data = { { 0, 0, 0, 0, 0 } }; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@id", id); data.l[0] = FIX2LONG(id); data.l[1] = SUB_EWMH_HIDDEN; subSharedMessage(display, DefaultRootWindow(display), "SUBTLE_SUBLET_FLAGS", data, 32, True); return self; } /* }}} */
VALUE subextViewJump(VALUE self) { VALUE id = Qnil; SubMessageData data = { { 0, 0, 0, 0, 0 } }; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@id", id); subextSubtlextConnect(NULL); ///< Implicit open connection /* Send message */ data.l[0] = FIX2INT(id); data.l[2] = -1; subSharedMessage(display, DefaultRootWindow(display), "_NET_CURRENT_DESKTOP", data, 32, True); return self; } /* }}} */
VALUE subextViewKill(VALUE self) { VALUE id = Qnil; SubMessageData data = { { 0, 0, 0, 0, 0 } }; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@id", id); subextSubtlextConnect(NULL); ///< Implicit open connection /* Send message */ data.l[0] = FIX2INT(id); subSharedMessage(display, DefaultRootWindow(display), "SUBTLE_VIEW_KILL", data, 32, True); rb_obj_freeze(self); ///< Freeze object return Qnil; } /* }}} */
/* ViewSelect {{{ */ static VALUE ViewSelect(VALUE self, int dir) { int nnames = 0; char **names = NULL; VALUE id = Qnil, ret = Qnil; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@id", id); subextSubtlextConnect(NULL); ///< Implicit open connection /* Fetch data */ if((names = subSharedPropertyGetStrings(display, DefaultRootWindow(display), XInternAtom(display, "_NET_DESKTOP_NAMES", False), &nnames))) { int vid = FIX2INT(id); /* Select view */ if(SUB_VIEW_NEXT == dir && vid < (nnames - 1)) { vid++; } else if(SUB_VIEW_PREV == dir && 0 < vid) { vid--; } /* Create view */ ret = subextViewInstantiate(names[vid]); subextViewUpdate(ret); XFreeStringList(names); } return ret; } /* }}} */
VALUE subextViewAskCurrent(VALUE self) { VALUE id = Qnil, ret = Qfalse;; unsigned long *cur_view = NULL; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@id", id); /* Check results */ if((cur_view = (unsigned long *)subSharedPropertyGet(display, DefaultRootWindow(display), XA_CARDINAL, XInternAtom(display, "_NET_CURRENT_DESKTOP", False), NULL))) { if(FIX2INT(id) == *cur_view) ret = Qtrue; free(cur_view); } return ret; } /* }}} */
/* ClientRestack {{{ */ VALUE ClientRestack(VALUE self, int detail) { VALUE win = Qnil; SubMessageData data = { { 0, 0, 0, 0, 0 } }; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@win", win); subextSubtlextConnect(NULL); ///< Implicit open connection /* Send message */ data.l[0] = 2; ///< Claim to be a pager data.l[1] = NUM2LONG(win); data.l[2] = detail; subSharedMessage(display, DefaultRootWindow(display), "_NET_RESTACK_WINDOW", data, 32, True); return self; } /* }}} */
VALUE subGravityGeometryReader(VALUE self) { VALUE geometry = Qnil, name = Qnil; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@name", name); /* Load on demand */ if(NIL_P((geometry = rb_iv_get(self, "@geometry")))) { XRectangle geom = { 0 }; GravityFindId(RSTRING_PTR(name), NULL, &geom); geometry = subGeometryInstantiate(geom.x, geom.y, geom.width, geom.height); rb_iv_set(self, "@geometry", geometry); } return geometry; } /* }}} */