summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-01-02 09:54:49 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-01-02 09:54:49 -0600
commitc5bca102dd4e45626e1e76b0684ef065935918ed (patch)
tree5f13e0b27facb5e725d31e13e4b77977bb2d76c5
parent6ddacfff536fc6fcedff929b315fd43c494bb02c (diff)
downloadtdelibs-c5bca102.tar.gz
tdelibs-c5bca102.zip
Add preferred icon metadata field
-rw-r--r--kfile-plugins/elf/kfile_elf.cpp4
-rw-r--r--kio/kio/kfileitem.cpp7
-rw-r--r--kio/kio/kurifilter.cpp7
-rw-r--r--kio/kio/tdelficon.cpp28
-rw-r--r--kio/kio/tdelficon.h10
-rw-r--r--tdelfeditor/tdelfeditor.cpp11
6 files changed, 60 insertions, 7 deletions
diff --git a/kfile-plugins/elf/kfile_elf.cpp b/kfile-plugins/elf/kfile_elf.cpp
index c657d245b..a26a6804b 100644
--- a/kfile-plugins/elf/kfile_elf.cpp
+++ b/kfile-plugins/elf/kfile_elf.cpp
@@ -97,6 +97,7 @@ KElfPlugin::KElfPlugin(TQObject *parent, const char *name,
item = addItemInfo(group, "Organization", i18n("Organization"), TQVariant::String);
item = addItemInfo(group, "Version", i18n("Version"), TQVariant::String);
item = addItemInfo(group, "DateTime", i18n("Creation Date/Time"), TQVariant::String);
+ item = addItemInfo(group, "SystemIcon", i18n("Requested Icon"), TQVariant::String);
item = addItemInfo(group, "Notes", i18n("Comments"), TQVariant::String);
item = addItemInfo(group2, "EmbeddedIcon", i18n("Icon Name(s)"), TQVariant::String);
@@ -126,6 +127,7 @@ bool KElfPlugin::readInfo( KFileMetaInfo& info, uint what)
appendItem(group, "Organization", elf_get_resource(handle, ".metadata_organization"));
appendItem(group, "Version", elf_get_resource(handle, ".metadata_version"));
appendItem(group, "DateTime", elf_get_resource(handle, ".metadata_datetime"));
+ appendItem(group, "SystemIcon", elf_get_resource(handle, ".metadata_sysicon"));
appendItem(group, "Notes", elf_get_resource(handle, ".metadata_notes"));
TQString iconListing;
@@ -143,7 +145,7 @@ bool KElfPlugin::readInfo( KFileMetaInfo& info, uint what)
iconListing = entry->name;
}
else {
- iconListing = iconListing.append("<p>").append(entry->name);
+ iconListing = iconListing.append("\n").append(entry->name);
}
break;
}
diff --git a/kio/kio/kfileitem.cpp b/kio/kio/kfileitem.cpp
index 40927f0cf..efb59043b 100644
--- a/kio/kio/kfileitem.cpp
+++ b/kio/kio/kfileitem.cpp
@@ -668,6 +668,13 @@ TQPixmap KFileItem::pixmap( int _size, int _state ) const
{
// Failed to obtain a list of ELF icons
kdWarning() << "failed to obtain ELF icon: " << libr_errmsg() << endl;
+
+ // See if there is a system icon we can use
+ TQString sysIconName = elf_get_resource(handle, ".metadata_sysicon");
+ if (KGlobal::iconLoader()->iconPath(sysIconName.ascii(), 0, true) != "") {
+ p = DesktopIcon( sysIconName.ascii(), _size, _state );
+ }
+
libr_close(handle);
return p;
}
diff --git a/kio/kio/kurifilter.cpp b/kio/kio/kurifilter.cpp
index 102d83166..24ed48328 100644
--- a/kio/kio/kurifilter.cpp
+++ b/kio/kio/kurifilter.cpp
@@ -216,6 +216,13 @@ TQString KURIFilterData::iconName()
{
// Failed to obtain a list of ELF icons
kdWarning() << "failed to obtain ELF icon: " << libr_errmsg() << endl;
+
+ // See if there is a system icon we can use
+ TQString sysIconName = elf_get_resource(handle, ".metadata_sysicon");
+ if (KGlobal::iconLoader()->iconPath(sysIconName.ascii(), 0, true) != "") {
+ m_customIconPixmap = DesktopIcon( sysIconName.ascii(), _size, _state );
+ }
+
libr_close(handle);
libr_can_continue = 0;
}
diff --git a/kio/kio/tdelficon.cpp b/kio/kio/tdelficon.cpp
index 8c5a0d9de..6e1e68169 100644
--- a/kio/kio/tdelficon.cpp
+++ b/kio/kio/tdelficon.cpp
@@ -58,4 +58,32 @@ iconentry *get_nexticon(iconlist *icons, iconentry *last_entry)
return NULL;
}
return &(icons->entry);
+}
+
+TQString elf_get_resource(libr_file *handle, char *section_name)
+{
+ size_t buffer_size = 0;
+ char *buffer = NULL;
+ TQString result;
+
+ /* Get the resource from the ELF binary */
+ if(!libr_size(handle, section_name, &buffer_size))
+ {
+ kdWarning() << "failed to obtain ELF resource size: " << libr_errmsg() << endl;
+ return result;
+ }
+ /* Get the resource from the ELF file */
+ buffer = (char *) malloc(buffer_size+1);
+ buffer[buffer_size] = 0;
+ if(!libr_read(handle, section_name, buffer))
+ {
+ kdWarning() << "failed to obtain ELF resource: " << libr_errmsg() << endl;
+ goto fail;
+ }
+ result = buffer;
+
+fail:
+ free(buffer);
+
+ return result;
} \ No newline at end of file
diff --git a/kio/kio/tdelficon.h b/kio/kio/tdelficon.h
index 7b17df818..7a962bdaa 100644
--- a/kio/kio/tdelficon.h
+++ b/kio/kio/tdelficon.h
@@ -1,8 +1,13 @@
-
#include <alloca.h>
#include <stdint.h>
#include <cstdlib>
+#include <tqdict.h>
+#include <tqvalidator.h>
+#include <tqcstring.h>
+#include <tqfile.h>
+#include <tqdatetime.h>
+
extern "C" {
#include <libr-icons.h>
@@ -45,4 +50,5 @@ extern "C" {
}
int get_iconlist(libr_file *file_handle, iconlist *icons);
-iconentry *get_nexticon(iconlist *icons, iconentry *last_entry); \ No newline at end of file
+iconentry *get_nexticon(iconlist *icons, iconentry *last_entry);
+TQString elf_get_resource(libr_file *handle, char *section_name); \ No newline at end of file
diff --git a/tdelfeditor/tdelfeditor.cpp b/tdelfeditor/tdelfeditor.cpp
index b6f52c199..4515474c6 100644
--- a/tdelfeditor/tdelfeditor.cpp
+++ b/tdelfeditor/tdelfeditor.cpp
@@ -73,7 +73,8 @@ typedef enum {
PARAM_ORGANIZATION = 9,
PARAM_VERSION = 10,
PARAM_DATETIME = 11,
- PARAM_NOTES = 12,
+ PARAM_SYSICON = 12,
+ PARAM_NOTES = 13,
} eParams;
typedef struct {
@@ -209,7 +210,7 @@ int handle_arguments(int argc, char **argv, eMode *mode)
break;
case 'm':
*mode = MODE_SET_METADATA;
- required_params = 13;
+ required_params = 14;
break;
case 'r':
*mode = MODE_RETRIEVE_ICON;
@@ -240,7 +241,7 @@ print_icon_usage:
fprintf(stderr, _("usage: %s [-c|-e|-g] elf-file-name\n"), argv[PARAM_PROGNAME]);
fprintf(stderr, _("usage: %s [-s] elf-file-name uuid\n"), argv[PARAM_PROGNAME]);
fprintf(stderr, _("usage: %s [-s] elf-file-name uuid\n"), argv[PARAM_PROGNAME]);
- fprintf(stderr, _("usage: %s [-m] elf-file-name \"executable name\" \"description\" \"license\" \"copyright\" \"authors\" \"product\" \"organization\" \"version\" \"datetime\" \"notes\"\n"), argv[PARAM_PROGNAME]);
+ fprintf(stderr, _("usage: %s [-m] elf-file-name \"executable name\" \"description\" \"license\" \"copyright\" \"authors\" \"product\" \"organization\" \"version\" \"datetime\" \"sysicon\" \"notes\"\n"), argv[PARAM_PROGNAME]);
fprintf(stderr, _("If -t is set the TDEDIRS environment variable must include your TDE installation prefix\n"));
fprintf(stderr, _("for example: TDEDIRS=/opt/trinity ./tdelfeditor -t ./konqueror konqueror\n"));
for(i=0;i<ELFICON_OPTIONS;i++)
@@ -490,6 +491,7 @@ int main_console(int argc, char **argv)
if (strlen(argv[PARAM_ORGANIZATION]) > 0) add_resource_string(handle, ".metadata_organization", argv[PARAM_ORGANIZATION]);
if (strlen(argv[PARAM_VERSION]) > 0) add_resource_string(handle, ".metadata_version", argv[PARAM_VERSION]);
if (strlen(argv[PARAM_DATETIME]) > 0) add_resource_string(handle, ".metadata_datetime", argv[PARAM_DATETIME]);
+ if (strlen(argv[PARAM_SYSICON]) > 0) add_resource_string(handle, ".metadata_sysicon", argv[PARAM_SYSICON]);
if (strlen(argv[PARAM_NOTES]) > 0) add_resource_string(handle, ".metadata_notes", argv[PARAM_NOTES]);
} break;
case MODE_SET_EMPTY_UUID:
@@ -546,7 +548,8 @@ int main_console(int argc, char **argv)
TQString systemIcon = KGlobal::iconLoader()->iconPath(argv[PARAM_ICON_NAME], 0, true);
if (systemIcon.isNull()) {
systemIcon = KGlobal::iconLoader()->iconPath(argv[PARAM_ICON_NAME], 0, false);
- printf("NOT FOUND, using %s\n\r", systemIcon.ascii());
+ printf("NOT FOUND, refusing to add unknown icon (this message is harmless)\n\r");
+ goto fail;
}
else {
printf("found %s\n\r", systemIcon.ascii());