GeolocationPositionCache::~GeolocationPositionCache() { if (!(--s_instances)) { if (*s_cachedPosition) writeToDB(s_cachedPosition->get()); delete s_cachedPosition; } }
BOOL fillTVStruct (xmlNodePtr parentTag) { xmlNode *seekChild, *curNode, *airNode; char *tmpString; char *toFree; /* clear Structs */ if (curTV->actors) free (curTV->actors); if (curTV->plot) free (curTV->plot); if (curTV->tagline) free (curTV->tagline); bzero (curTV, sizeof(struct ST_tv)); if ( (seekChild = getChildNodeByName(parentTag, "title")) != NULL ) { if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) { strncat(curTV->seriesname, tmpString, 255); free (tmpString); printD ("Stored Title:%s\n", curTV->seriesname); } } else { printD("Something went wrong while reading title...\n"); return (FALSE); } if ( (seekChild = getChildNodeByName(parentTag, "language")) != NULL ) { if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) { strncat(curTV->language, tmpString, 255); free (tmpString); printD ("Stored Language:%s\n", curTV->language); } } else { printD("Something went wrong while reading language...\n"); return (FALSE); } if ( (seekChild = getChildNodeByName(parentTag, "container")) != NULL ) { if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) { strncat(curTV->mediatype, tmpString, 255); xmlFree (tmpString); printD ("Stored MediaType:%s\n", curTV->mediatype); } } else { printD("Something went wrong while reading container(mediatype)...\n"); return (FALSE); } if ( (toFree = getIDs(parentTag)) != NULL ) { sprintf (curTV->imdblink, "http://www.imdb.com/title/%s\n", toFree); free (toFree); } else sprintf (curTV->imdblink, "http://www.imdb.com/find?s=all&q=%s", curMovie->moviename); printD ("Stored IMDBLink:%s\n", curTV->imdblink); if ( (seekChild = getChildNodeByName(parentTag, "videoOutput")) != NULL) { if ( (tmpString = (char*)xmlNodeGetContent (seekChild)) != NULL) { curMovie->isHD = isHD(tmpString); xmlFree ((xmlChar*)tmpString); } } else curMovie->isHD = FALSE; if ( (seekChild = getChildNodeByName(parentTag, "directors")) != NULL ) { if ( childTextToString(seekChild, curTV->directors, "director") == 0 ) strcat (curTV->directors, "UNKNOWN"); printD ("Stored Directors:%s\n", curTV->directors); } else { printD("Something went wrong while reading directors...\n"); } if ( (seekChild = getChildNodeByName(parentTag, "writers")) != NULL ) { if ( childTextToString(seekChild, curTV->writers, "writer") == 0 ) strcat (curTV->writers, "UNKNOWN"); printD ("Stored Writers:%s\n", curTV->writers); } if ( (seekChild = getChildNodeByName(parentTag, "genres")) != NULL ) { if ( childTextToString(seekChild, curTV->genres, "genre") == 0 ) strcat (curTV->genres, "UNKNOWN"); printD ("Stored Genres:%s\n", curTV->genres); } if ( (seekChild = getChildNodeByName(parentTag, "cast")) != NULL ) { if ( childTextToString_m(seekChild, &curTV->actors, "actor") == 0 ) curTV->actors = strdup ("UNKNOWN"); printD ("Stored Actors:%s\n", curTV->actors); } else curTV->actors = strdup ("UNKNOWN"); if ( (seekChild = getChildNodeByName(parentTag, "tagline")) != NULL ) { if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) { curTV->tagline=tmpString; printD ("Stored Outline:%s\n", curTV->tagline); } } if ( (seekChild = getChildNodeByName(parentTag, "plot")) != NULL ) { if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) { curTV->plot=tmpString; printD ("Stored Plot:%s\n", curTV->plot); } } if ( (seekChild = getChildNodeByName(parentTag, "releaseDate")) != NULL ) { if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) { strncat (curTV->year, tmpString, 63); xmlFree (tmpString); printD ("Stored Releasedate:%s\n", curTV->year); } } if ( (seekChild = getChildNodeByName(parentTag, "posterFile")) != NULL ) { if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) { strncat (curTV->imglink, tmpString, 255); free (tmpString); printD ("Stored Imagelink:%s\n", curTV->imglink); } } if ( (seekChild = getChildNodeByName(parentTag, "rating")) != NULL ) { if ( ( tmpString = (char*)xmlNodeGetContent(seekChild)) != NULL ) { if (atoi((char*)tmpString) < 0) curTV->rating=0; else curTV->rating=atoi((char*)tmpString); xmlFree (tmpString); printD ("Stored Rating:%i\n", curTV->rating); } } if ( (seekChild = getChildNodeByName(parentTag, "season")) != NULL ) { if ( ( tmpString = (char*)xmlNodeGetContent(seekChild)) != NULL ) { if (atoi((char*)tmpString) < 0) curTV->season=0; else curTV->season=atoi((char*)tmpString); xmlFree (tmpString); printD ("Stored Season:%i\n", curTV->season); } } if ( (seekChild = getChildNodeByName(parentTag, "files")) != NULL) { if (seekChild->children) { curNode = seekChild->children; while (curNode) { if (curNode->type == XML_ELEMENT_NODE) { if (strcasecmp((char*)curNode->name, "file") == 0) { if ( (airNode = getChildNodeByName(curNode, "fileTitle")) != NULL) { if ( (tmpString = (char*)xmlGetProp(airNode, (xmlChar*)"part")) != NULL ) { if (atoi((char*)tmpString) < 0 ) curTV->episode=0; else curTV->episode=atoi((char*)tmpString); xmlFree (tmpString); } if ( (tmpString = encNodeGetContent(airNode)) != NULL ) { strncat (curTV->episodename, tmpString, 255); free(tmpString); } } if ( (airNode = getChildNodeByName(curNode, "fileLocation")) != NULL) { tmpString = (char*)xmlNodeGetContent(airNode); strncat (curTV->filename, tmpString ? tmpString : "*UNAVAILABLE*", 255); if (tmpString) free (tmpString); } } if (!writeToDB(TRUE)) fprintf (stderr, "%s could not be stored in DB:%s\n", curTV->filename, mysql_error(mysql_conn)); bzero(curTV->episodename, 255); bzero(curTV->filename, 255); } /* should all be filled by now, pump it in the DB */ curNode=curNode->next; } } } return (TRUE); }