bool RSSEditPopup::Create(void) { // Load the theme for this screen bool foundtheme = LoadWindowFromXML("netvision-ui.xml", "rsseditpopup", this); if (!foundtheme) return false; bool err = false; UIUtilE::Assign(this, m_urlEdit, "url", &err); UIUtilE::Assign(this, m_titleEdit, "title", &err); UIUtilE::Assign(this, m_descEdit, "description", &err); UIUtilE::Assign(this, m_authorEdit, "author", &err); UIUtilE::Assign(this, m_download, "download", &err); UIUtilE::Assign(this, m_okButton, "ok", &err); UIUtilE::Assign(this, m_cancelButton, "cancel", &err); UIUtilE::Assign(this, m_thumbButton, "preview_browse", &err); UIUtilE::Assign(this, m_thumbImage, "preview", &err); if (err) { VERBOSE(VB_IMPORTANT, "Cannot load screen 'rsseditpopup'"); return false; } connect(m_okButton, SIGNAL(Clicked()), this, SLOT(parseAndSave())); connect(m_cancelButton, SIGNAL(Clicked()), this, SLOT(Close())); connect(m_thumbButton, SIGNAL(Clicked()), this, SLOT(doFileBrowser())); m_urlEdit->SetMaxLength(0); m_titleEdit->SetMaxLength(255); m_descEdit->SetMaxLength(0); m_authorEdit->SetMaxLength(255); if (m_editing) { m_site = findByURL(m_urlText, VIDEO_PODCAST); m_urlEdit->SetText(m_urlText); m_titleEdit->SetText(m_site->GetTitle()); m_descEdit->SetText(m_site->GetDescription()); m_authorEdit->SetText(m_site->GetAuthor()); QString thumb = m_site->GetImage(); if (!thumb.isEmpty()) { m_thumbImage->SetFilename(thumb); m_thumbImage->Load(); } if (m_site->GetDownload() == 1) m_download->SetCheckState(MythUIStateType::Full); } BuildFocusList(); return true; }
char Initialize(char* path){ char buf[BUFFSIZE]; char* line=NULL; size_t basicsize=BUFFSIZE; dictionary = DictionaryInitialize(); if(path==NULL){ //if d return 0; } FILE* file=fopen(path,"r"); if(file==NULL){ //if file does not exist don't try to read, write only errno=0; return 0; } while (!feof(file)){ if(fgets(buf, BUFFSIZE, file)==NULL){ //Noth more to read, but we can have line saved before, can we? if(line==NULL) break; parseAndSave(line); free(line); line=NULL; break; } line=(char*) realloc(line,basicsize); //buffsize if (line==NULL){ perror("Dictionary Initialize realloc line failed"); free(line); fclose(file); return 0; } if(basicsize==BUFFSIZE){ line[0]='\0'; } basicsize+=BUFFSIZE; size_t ssize = strlen(buf);//figure out the actual length we read if (ssize==BUFFSIZE-1){ strcat(line, buf); //if we read whole bytes we requested if(buf[ssize-1]=='\n'){ //we got lion^W line, everybody get in a car if(parseAndSave(line)!=0){ free(line); fclose(file); return -1; } free(line); basicsize=BUFFSIZE; line=NULL; } continue; //if we did not met EOF or '\n' keep reading that same file } strcat(line,buf); if(parseAndSave(line)!=0){ free(line); fclose(file); return -1; } parseAndSave(line); free(line); line=NULL; basicsize=BUFFSIZE; // if we somehow read the other amount of chars } if(errno!=0){ perror("Error while Reading file"); fclose(file); return -1; } fclose(file); return 0; }