diff --git a/ChangeLog b/ChangeLog index 96ef290..02c9282 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,10 +13,14 @@ *************************************** BUGS: -Please send them direct to me at:keithhedger@keithhedger.darktech.org posting them on xfce-look etc gets too messy! +Please send them direct to me at:kdhedger68713@.gmail.com. *************************************** Changelog: +0.3.9 + Removed redundant xfdesktop --reload. + Buffer overflow fixes. + Minor changes to xconf settings. 0.3.8 Added new release. Removed release with broken links. diff --git a/Xfce-Theme-Manager/src/callbacks.cpp b/Xfce-Theme-Manager/src/callbacks.cpp index 573a482..23f16bb 100644 --- a/Xfce-Theme-Manager/src/callbacks.cpp +++ b/Xfce-Theme-Manager/src/callbacks.cpp @@ -176,7 +176,7 @@ void changeViewWhat(GtkWidget* widget,gpointer data) rerunAndUpdate(false,true); } -void buildCustomDB(const char* chan,const char* prop,dataType type,const char* key) +void buildCustomDB(const char* chan,const char* prop,dataType type,const char* key,FILE *fd) { char* strdata=NULL; int intdata; @@ -186,18 +186,18 @@ void buildCustomDB(const char* chan,const char* prop,dataType type,const char* k { case INT: getValue(chan,prop,type,&intdata); - sprintf(filedata,"%s%s=%i\n",filedata,key,intdata); + fprintf(fd,"%s=%i\n",key,intdata); break; case STRING: getValue(chan,prop,type,&strdata); - sprintf(filedata,"%s%s=%s\n",filedata,key,strdata); + fprintf(fd,"%s=%s\n",key,strdata); g_free(strdata); break; case FLOAT: getValue(chan,prop,type,&floatdata); - sprintf(filedata,"%s%s=%f\n",filedata,key,floatdata); + fprintf(fd,"%s=%f\n",key,floatdata); break; case COLOURARRAY: @@ -219,9 +219,9 @@ void response(GtkDialog *dialog,gint response_id,gpointer user_data) asprintf(&filename,"%s",gtk_entry_get_text((GtkEntry*)entryBox)); if (filename!=NULL && strlen(filename)>0) { - sprintf(generalBuffer,"%s/%s.db",customFolder,filename); + sprintf(filedata,"%s/%s.db",customFolder,filename); remove(generalBuffer); - sprintf(generalBuffer,"%s/%s.png",customFolder,filename); + sprintf(filedata,"%s/%s.png",customFolder,filename); remove(generalBuffer); freeAndNull(&filename); rerunAndUpdate(true,true); @@ -302,42 +302,42 @@ void customTheme(GtkWidget* window,gpointer data) fd=fopen(dbname,"w"); if(fd!=NULL) { - sprintf(filedata,"[Data]\nName=%s\nThumbnail=%s\n",filename,thumbfile); - buildCustomDB(XSETTINGS,CONTROLTHEMEPROP,STRING,"GtkTheme"); - buildCustomDB(XSETTINGS,ICONTHEMEPROP,STRING,"IconTheme"); - buildCustomDB(XSETTINGS,CURSORSPROP,STRING,"CursorTheme"); - buildCustomDB(XFWM,WMBORDERSPROP,STRING,"Xfwm4Theme"); + fprintf(fd,"[Data]\nName=%s\nThumbnail=%s\n",filename,thumbfile); + buildCustomDB(XSETTINGS,CONTROLTHEMEPROP,STRING,"GtkTheme",fd); + buildCustomDB(XSETTINGS,ICONTHEMEPROP,STRING,"IconTheme",fd); + buildCustomDB(XSETTINGS,CURSORSPROP,STRING,"CursorTheme",fd); + buildCustomDB(XFWM,WMBORDERSPROP,STRING,"Xfwm4Theme",fd); - buildCustomDB(XFWM,BUTTONLAYOUTPROP,STRING,"TitleButtonLayout"); - buildCustomDB(XFWM,TITLEALIGNPROP,STRING,"TitlePosition"); - buildCustomDB(XFWM,WMFONTPROP,STRING,"WMFont"); - buildCustomDB(XSETTINGS,APPFONTPROP,STRING,"AppFont"); + buildCustomDB(XFWM,BUTTONLAYOUTPROP,STRING,"TitleButtonLayout",fd); + buildCustomDB(XFWM,TITLEALIGNPROP,STRING,"TitlePosition",fd); + buildCustomDB(XFWM,WMFONTPROP,STRING,"WMFont",fd); + buildCustomDB(XSETTINGS,APPFONTPROP,STRING,"AppFont",fd); - buildCustomDB(XSETTINGS,CURSORSIZEPROP,INT,"CursorSize"); + buildCustomDB(XSETTINGS,CURSORSIZEPROP,INT,"CursorSize",fd); //backdrop stuff for(int j=0; jimagePath); - sprintf(filedata,"%sBackdropStyle=%i\n",filedata,monitorData[j]->style); - sprintf(filedata,"%sBackdropBright=%i\n",filedata,monitorData[j]->brightness); - sprintf(filedata,"%sBackdropSatu=%f\n",filedata,monitorData[j]->satu); + fprintf(fd,"[Monitor-%i]\n",j); + fprintf(fd,"BackgroundImage=%s\n",monitorData[j]->imagePath); + fprintf(fd,"BackdropStyle=%i\n",monitorData[j]->style); + fprintf(fd,"BackdropBright=%i\n",monitorData[j]->brightness); + fprintf(fd,"BackdropSatu=%f\n",monitorData[j]->satu); } //panel stuff for(int j=0; jpanelNumber); - sprintf(filedata,"%sPanelImage=%s\n",filedata,panels[j]->imagePath); - sprintf(filedata,"%sPanelStyle=%i\n",filedata,panels[j]->style); - sprintf(filedata,"%sPanelSize=%i\n",filedata,panels[j]->size); - sprintf(filedata,"%sPanelAlpha=%i\n",filedata,panels[j]->alpha); - sprintf(filedata,"%sPanelRed=%i\n",filedata,panels[j]->red); - sprintf(filedata,"%sPanelGreen=%i\n",filedata,panels[j]->green); - sprintf(filedata,"%sPanelBlue=%i\n",filedata,panels[j]->blue); + + fprintf(fd,"[Panel-%i]\n",panels[j]->panelNumber); + fprintf(fd,"PanelImage=%s\n",panels[j]->imagePath); + fprintf(fd,"PanelStyle=%i\n",panels[j]->style); + fprintf(fd,"PanelSize=%i\n",panels[j]->size); + fprintf(fd,"PanelAlpha=%i\n",panels[j]->alpha); + fprintf(fd,"PanelRed=%i\n",panels[j]->red); + fprintf(fd,"PanelGreen=%i\n",panels[j]->green); + fprintf(fd,"PanelBlue=%i\n",panels[j]->blue); } - fprintf(fd,"%s\n",filedata); fclose(fd); controlWidth=400; @@ -455,14 +455,14 @@ int extractAndInstall(char* filename,int ziptype) while(true) { - sprintf(generalBuffer,"%s \"%s\" */gtkrc",commandtest,filename); + sprintf(filedata,"%s \"%s\" */gtkrc",commandtest,filename); g_spawn_command_line_sync((char*)generalBuffer,&stdout,&stderr,&spawnret,NULL); if (spawnret==0) { stdout[strlen(stdout)-1]=0; if(strlen(stdout)>1) { - sprintf(generalBuffer,"%s \"%s\"",commandextracttheme,filename); + sprintf(filedata,"%s \"%s\"",commandextracttheme,filename); retval=system(generalBuffer); freeAndNull(&stdout); break; @@ -470,14 +470,14 @@ int extractAndInstall(char* filename,int ziptype) freeAndNull(&stdout); } - sprintf(generalBuffer,"%s \"%s\" */themerc",commandtest,filename); + sprintf(filedata,"%s \"%s\" */themerc",commandtest,filename); g_spawn_command_line_sync((char*)generalBuffer,&stdout,&stderr,&spawnret,NULL); if (spawnret==0) { stdout[strlen(stdout)-1]=0; if(strlen(stdout)>1) { - sprintf(generalBuffer,"%s \"%s\"",commandextracttheme,filename); + sprintf(filedata,"%s \"%s\"",commandextracttheme,filename); retval=system(generalBuffer); freeAndNull(&stdout); freeAndNull(&stderr); @@ -487,14 +487,14 @@ int extractAndInstall(char* filename,int ziptype) freeAndNull(&stderr); } - sprintf(generalBuffer,"%s \"%s\" */index.theme",commandtest,filename); + sprintf(filedata,"%s \"%s\" */index.theme",commandtest,filename); g_spawn_command_line_sync((char*)generalBuffer,&stdout,&stderr,&spawnret,NULL); if (spawnret==0) { stdout[strlen(stdout)-1]=0; if(strlen(stdout)>1) { - sprintf(generalBuffer,"%s \"%s\"",commandextracticon,filename); + sprintf(filedata,"%s \"%s\"",commandextracticon,filename); retval=system(generalBuffer); freeAndNull(&stdout); freeAndNull(&stderr); @@ -529,13 +529,13 @@ void dropUri(GtkWidget *widget,GdkDragContext *context,gint x,gint y,GtkSelectio //make sure folders are there //themes - sprintf(generalBuffer,"mkdir -p %s/.themes",homeFolder); + sprintf(filedata,"mkdir -p %s/.themes",homeFolder); system(generalBuffer); //icons etc - sprintf(generalBuffer,"mkdir -p %s/.icons",homeFolder); + sprintf(filedata,"mkdir -p %s/.icons",homeFolder); system(generalBuffer); //pics - sprintf(generalBuffer,"mkdir -p %s/.local/share/xfce4/backdrops",homeFolder); + sprintf(filedata,"mkdir -p %s/.local/share/xfce4/backdrops",homeFolder); system(generalBuffer); //themes @@ -646,7 +646,7 @@ void removeTheme(const char* name) if(gtk_dialog_run (GTK_DIALOG(dialog))==GTK_RESPONSE_YES) { namelen=strlen(name); - sprintf(generalBuffer,"%s",name); + sprintf(filedata,"%s",name); remove(name); generalBuffer[namelen-2]='p'; generalBuffer[namelen-1]='n'; @@ -907,8 +907,6 @@ void doMeta(char* metaFilename) if(keydata!=NULL) g_key_file_free(keyfile); - - system("xfdesktop --reload"); } void setPieceNewNew(const char* filePath,long doWhat) diff --git a/Xfce-Theme-Manager/src/cli.cpp b/Xfce-Theme-Manager/src/cli.cpp index 770c2d8..9a6e99a 100644 --- a/Xfce-Theme-Manager/src/cli.cpp +++ b/Xfce-Theme-Manager/src/cli.cpp @@ -138,7 +138,9 @@ int doCliThemePart(char* name,long what) papername=getThemeNameFromDB(generalBuffer); if(papername!=NULL) { - sprintf((char*)&generalBuffer[0],"%s%i/image-path",MONITORPROP,cliMonitor); + sprintf((char*)&generalBuffer[0],"%s%s/workspace0/last-image",MONITORPROP,monitorData[cliMonitor]->name); + setValue(XFCEDESKTOP,(char*)&generalBuffer[0],STRING,papername); + sprintf((char*)&generalBuffer[0],"%s%i/workspace0/last-image",MONITORPROP,cliMonitor); setValue(XFCEDESKTOP,(char*)&generalBuffer[0],STRING,papername); return(0); } diff --git a/Xfce-Theme-Manager/src/database.cpp b/Xfce-Theme-Manager/src/database.cpp index 0236f89..bfdb1d0 100644 --- a/Xfce-Theme-Manager/src/database.cpp +++ b/Xfce-Theme-Manager/src/database.cpp @@ -258,17 +258,17 @@ gpointer rebuildDB(gpointer data) { if (g_file_test(dbFolder,G_FILE_TEST_IS_DIR)) { - sprintf(generalBuffer,"rm -r %s",metaFolder); + snprintf(generalBuffer,GENBUFFERSIZE,"rm -r %s",metaFolder); system(generalBuffer); - sprintf(generalBuffer,"rm -r %s",framesFolder); + snprintf(generalBuffer,GENBUFFERSIZE,"rm -r %s",framesFolder); system(generalBuffer); - sprintf(generalBuffer,"rm -r %s",controlsFolder); + snprintf(generalBuffer,GENBUFFERSIZE,"rm -r %s",controlsFolder); system(generalBuffer); - sprintf(generalBuffer,"rm -r %s",iconsFolder); + snprintf(generalBuffer,GENBUFFERSIZE,"rm -r %s",iconsFolder); system(generalBuffer); - sprintf(generalBuffer,"rm -r %s",cursorsFolder); + snprintf(generalBuffer,GENBUFFERSIZE,"rm -r %s",cursorsFolder); system(generalBuffer); - sprintf(generalBuffer,"rm -r %s",wallpapersFolder); + snprintf(generalBuffer,GENBUFFERSIZE,"rm -r %s",wallpapersFolder); system(generalBuffer); } } @@ -556,7 +556,7 @@ gpointer rebuildDB(gpointer data) entry=g_dir_read_name(folder); while(entry!=NULL) { - sprintf(generalBuffer,"%s/%s",papersArray[i],entry); + snprintf(generalBuffer,GENBUFFERSIZE,"%s/%s",papersArray[i],entry); if(g_file_test(generalBuffer,G_FILE_TEST_IS_DIR)==false) { asprintf(&dbfile,"%s/%i.%s.db",wallpapersFolder,i,entry); diff --git a/Xfce-Theme-Manager/src/globals.cpp b/Xfce-Theme-Manager/src/globals.cpp index c75e029..0b50221 100644 --- a/Xfce-Theme-Manager/src/globals.cpp +++ b/Xfce-Theme-Manager/src/globals.cpp @@ -126,9 +126,9 @@ int controlHeight=64; int controlWidth=256; GdkPixbuf* controlsPixbuf; -GtkNotebook* notebook; +GtkNotebook* notebook; -char generalBuffer[4096]; +char generalBuffer[GENBUFFERSIZE]; GdkPixbuf* missingImage; GdkPixbuf* blankImage; diff --git a/Xfce-Theme-Manager/src/globals.h b/Xfce-Theme-Manager/src/globals.h index d09a124..37673c4 100644 --- a/Xfce-Theme-Manager/src/globals.h +++ b/Xfce-Theme-Manager/src/globals.h @@ -84,6 +84,8 @@ #define _translate(x) langStr[langID][x] #define _translateHelp(x) helpStr[langID][x] +#define GENBUFFERSIZE 8192 + enum {ENGLISH=0,SPANISH,GERMAN,POLISH,FRENCH,PORTUGUESE,NONE}; enum dataType {INT,BOOLEAN,STRING,FLOAT,COLOURARRAY}; @@ -109,7 +111,7 @@ extern char* currentButtonLayout; extern char* currentTitlePos; extern char* currentWMFont; extern char* currentAppFont; -extern int currentCursSize; +extern int currentCursSize; extern char* currentMetaTheme; extern char* originalGtkTheme; @@ -120,7 +122,7 @@ extern char* originalWallpaper; extern char* originalMetaTheme; extern char* homeThemesHash; -extern bool initing; +extern bool initing; struct boxStruct { @@ -233,7 +235,7 @@ extern int controlWidth; extern GdkPixbuf* controlsPixbuf; extern GtkNotebook* notebook; -extern char generalBuffer[4096]; +extern char generalBuffer[GENBUFFERSIZE]; extern GdkPixbuf* missingImage; extern GdkPixbuf* blankImage; diff --git a/Xfce-Theme-Manager/src/main.cpp b/Xfce-Theme-Manager/src/main.cpp index 8deb401..c121502 100644 --- a/Xfce-Theme-Manager/src/main.cpp +++ b/Xfce-Theme-Manager/src/main.cpp @@ -219,6 +219,27 @@ void initFolders(void) asprintf(&customFolder,"%s/custom",dbFolder); } +void getmonames(void) +{ + FILE* fp; + char line[256]; + +char *generalBuffer; +asprintf(&generalBuffer,"xrandr|grep -i '\\bconnected'|awk '{print $1}'"); +int cnt=0; + + fp=popen(generalBuffer, "r"); + while(fgets(line,255,fp)) + { + if(strlen(line)>0) + { + line[strlen(line)-1]=0; + asprintf(&monitorData[cnt++]->name,"%s",line); + } + } + pclose(fp); +} + void init(void) { gchar *stdout=NULL; @@ -284,11 +305,12 @@ void init(void) #else sprintf((char*)&generalBuffer[0],"%s%i/image-style",MONITORPROP,i); #endif - getValue(XFCEDESKTOP,(char*)&generalBuffer[0],INT,&monitorData[i]->style); revertMonitorData[i]->style=monitorData[i]->style; } + getmonames(); + //mouse getValue(XSETTINGS,CURSORSPROP,STRING,¤tCursorTheme); getValue(XSETTINGS,CURSORSPROP,STRING,&originalCursorTheme); @@ -390,7 +412,7 @@ void init(void) { for(int j=0; jname); gtk_combo_box_text_append_text((GtkComboBoxText*)screenNumber,generalBuffer); g_signal_connect_after(G_OBJECT(screenNumber),"changed",G_CALLBACK(monitorChanged),NULL); } @@ -471,7 +493,7 @@ void printName(const char* section,char* folderName) { if(strstr(entry,".db")) { - sprintf(generalBuffer,"%s\n",&entry[2]); + snprintf(generalBuffer,GENBUFFERSIZE,"%s\n",&entry[2]); generalBuffer[strlen(entry)-5]=0; printf("%s\n",generalBuffer); } @@ -505,7 +527,7 @@ void printList(void) { if(strstr(entry,".db")) { - sprintf(generalBuffer,"%s\n",entry); + snprintf(generalBuffer,GENBUFFERSIZE,"%s\n",entry); generalBuffer[strlen(generalBuffer)-4]=0; printf("%s\n",generalBuffer); } @@ -629,6 +651,20 @@ int main(int argc,char **argv) xfconf_init(NULL); initFolders(); + fflush(stderr); + fgetpos(stderr,&pos); + fd=dup(fileno(stderr)); + freopen("/dev/null","w",stderr); + +#if GLIB_MINOR_VERSION < PREFERVERSION + g_thread_init(NULL); +#endif + gdk_threads_init(); + gdk_threads_enter(); + gtk_init(&argc,&argv); + + init(); + while (1) { int option_index=0; @@ -758,19 +794,6 @@ int main(int argc,char **argv) } } - fflush(stderr); - fgetpos(stderr,&pos); - fd=dup(fileno(stderr)); - freopen("/dev/null","w",stderr); - -#if GLIB_MINOR_VERSION < PREFERVERSION - g_thread_init(NULL); -#endif - gdk_threads_init(); - gdk_threads_enter(); - gtk_init(&argc,&argv); - - init(); initing=false; if(doPrintHelp==true) @@ -782,7 +805,7 @@ int main(int argc,char **argv) if(checkFolders()!=0) updateDb=true; - sprintf(generalBuffer,"%s/.config/XfceThemeManager",homeFolder); + snprintf(generalBuffer,GENBUFFERSIZE,"%s/.config/XfceThemeManager",homeFolder); dbexists=g_file_test(generalBuffer,G_FILE_TEST_IS_DIR); if ((rebuildDb==true) || (dbexists==false)) @@ -954,7 +977,6 @@ int main(int argc,char **argv) if (cliIcons!=NULL) { cliRetVal|=doCliThemePart(cliIcons,ICONS); - system("xfdesktop --reload"); } if (cliCursors!=NULL) diff --git a/configure.ac b/configure.ac index a166987..838d946 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ # # -AC_INIT([Xfce-Theme-Manager],[0.3.8],[PROJ],[Xfce-Theme-Manager]) +AC_INIT([Xfce-Theme-Manager],[0.3.9],[PROJ],[Xfce-Theme-Manager]) AC_CONFIG_HEADER([config.h]) AC_PROG_CXX