From 43f19fb8a02775dca1d0701f7a7eb3ce775439ff Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sat, 31 Dec 2011 14:17:08 -0600 Subject: [PATCH] Add mising files --- CMakeLists.txt | 4 +-- kio/kio/tdelficon.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++ kio/kio/tdelficon.h | 48 ++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 kio/kio/tdelficon.cpp create mode 100644 kio/kio/tdelficon.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 86c2fcdda..4e8a6902c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -729,9 +729,9 @@ if( WITH_ELFICON ) if( NOT LIBR_FOUND ) message(FATAL_ERROR "\nelficon support was requested, but libr was not found on your system" ) endif( NOT LIBR_FOUND ) - if( LIBR_VERSION != 0.6.0 ) + if( NOT "${LIBR_VERSION}" STREQUAL "0.6.0" ) message(FATAL_ERROR "\nelficon support was requested, but the libr version on your system may not be compatible with TDE" ) - endif( LIBR_VERSION != 0.6.0 ) + endif( NOT "${LIBR_VERSION}" STREQUAL "0.6.0" ) set( HAVE_ELFICON 1 ) endif( ) diff --git a/kio/kio/tdelficon.cpp b/kio/kio/tdelficon.cpp new file mode 100644 index 000000000..8c5a0d9de --- /dev/null +++ b/kio/kio/tdelficon.cpp @@ -0,0 +1,61 @@ +#include "tdelficon.h" + +#include + +/* + * Obtain an existing icon resource list + */ +int get_iconlist(libr_file *file_handle, iconlist *icons) +{ + if(icons == NULL) + { + /* Need to be able to return SOMETHING */ + return false; + } + /* Obtain the icon resource list */ + icons->buffer = libr_malloc(file_handle, ICON_SECTION, &(icons->size)); + if(icons->buffer == NULL) + return false; + return true; +} + +/* + * Get the next entry in an icon resource list + */ +iconentry *get_nexticon(iconlist *icons, iconentry *last_entry) +{ + size_t i; + + /* The icon list is needed both for the data buffer and for a call-specific iconentry instance */ + if(icons == NULL) + return NULL; + /* If this is the first call (last_entry == NULL) then return the first entry */ + if(last_entry == NULL) + icons->entry.offset = sizeof(uint32_t)+sizeof(UUID); + else + icons->entry.offset += icons->entry.entry_size; + /* Check to see if we've run out of entries */ + if(icons->entry.offset >= icons->size) + return NULL; + i = icons->entry.offset; + memcpy(&(icons->entry.entry_size), &(icons->buffer[i]), sizeof(uint32_t)); + i += sizeof(uint32_t); + icons->entry.type = (libr_icontype_t)icons->buffer[i]; + i += sizeof(unsigned char); + switch(icons->entry.type) + { + case LIBR_SVG: + icons->entry.icon_size = 0; + icons->entry.name = &(icons->buffer[i]); + break; + case LIBR_PNG: + memcpy(&(icons->entry.icon_size), &(icons->buffer[i]), sizeof(uint32_t)); + i += sizeof(uint32_t); + icons->entry.name = &(icons->buffer[i]); + break; + default: + /* Invalid entry type */ + return NULL; + } + return &(icons->entry); +} \ No newline at end of file diff --git a/kio/kio/tdelficon.h b/kio/kio/tdelficon.h new file mode 100644 index 000000000..7b17df818 --- /dev/null +++ b/kio/kio/tdelficon.h @@ -0,0 +1,48 @@ + +#include +#include +#include + +extern "C" { + #include + + // BEGIN HACK + // libr does not export these structures and defines, + // but we need access to them to make the UI behave sanely + // Keep them in sync with libr and all should be OK + + // Valid for libr version 0.6.0 + // See libr detection code in ConfigureChecks.cmake + + typedef uint32_t ID8; + typedef uint16_t ID4; + typedef struct {uint64_t p:48;} __attribute__((__packed__)) ID12; + + typedef struct { + ID8 g1; + ID4 g2; + ID4 g3; + ID4 g4; + ID12 g5; + } __attribute__((__packed__)) UUID; + + typedef struct { + char *name; + size_t offset; + size_t entry_size; + libr_icontype_t type; + unsigned int icon_size; + } iconentry; + + typedef struct{ + size_t size; + char *buffer; + iconentry entry; + } iconlist; + + #define ICON_SECTION ".icon" + // END HACK +} + +int get_iconlist(libr_file *file_handle, iconlist *icons); +iconentry *get_nexticon(iconlist *icons, iconentry *last_entry); \ No newline at end of file