*
*/
+#include <unzip.h>
+
#include "setting-license.h"
#define TEXT_CLEAR_LICENSE "IDS_ST_BODY_REMOVE_LICENCE"
#define SETTING_DIVX_MODE_DEREG 1
#define SETTING_LICESE_SAMSUNG_LEGAL "IDS_ST_BODY_SAMSUNG_LEGAL"
+#if SUPPORT_COMPRESSED_LICENSE
+#define UNCOMPRESSEDFILE_DIR "/home/owner/apps_rw/org.tizen.setting/data"
+#endif
+
+
static void __mouse_up_Gendial_list_cb(void *data,
Evas_Object *obj, void *event_info);
static int _view_create(void *cb);
app_control_result_e result_code, void *priv)
{
SETTING_TRACE_BEGIN;
+#if SUPPORT_COMPRESSED_LICENSE
+ char tempfilename[256]; // for temp file
+#endif
SettingLicenseData *ad = (SettingLicenseData *)priv;
ret_if(!ad);
SETTING_TRACE("webkit_address = %s", webkit_address);
add_app_reply(&ad->md, "webkit_address", webkit_address);
FREE(webkit_address);
+
+#if SUPPORT_COMPRESSED_LICENSE
+ // remove temorary file
+ snprintf(tempfilename,256, "%s/license.html", UNCOMPRESSEDFILE_DIR);
+ remove(tempfilename);
+#endif
+ }
+
+}
+
+
+
+
+
+
+#if SUPPORT_COMPRESSED_LICENSE
+
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+
+#define WRITEBUFFERSIZE (1024*1024*3) // 3Mb buffer
+
+static int readZipFile(char *zipFile, char *fileInZip)
+{
+ SETTING_TRACE_BEGIN;
+
+ int err = UNZ_OK; // error status
+ uInt size_buf = WRITEBUFFERSIZE; // byte size of buffer to store raw data
+ void* buf; // the buffer
+ char filename_inzip[256]; // for unzGetCurrentFileInfo
+ unz_file_info file_info; // for unzGetCurrentFileInfo
+ char tempfilename[256]; // for temp file
+ FILE *tempfile_fp = 0;
+
+
+ unzFile uf = unzOpen(zipFile); // open zipfile stream
+ if (uf == NULL) {
+ SETTING_TRACE("Cannot open %s", zipFile);
+ return -1;
+ } // file is open
+
+ if ( unzLocateFile(uf,fileInZip,1) ) { // try to locate file inside zip
+ // second argument of unzLocateFile: 1 = case sensitive, 0 = case-insensitive
+ SETTING_TRACE("File %s not found in %s", fileInZip, zipFile);
+ return -1;
+ } // file inside zip found
+
+ if (unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0)) {
+ SETTING_TRACE("Error %d with zipfile %s in unzGetCurrentFileInfo.", err, zipFile);
+ return -1;
+ } // obtained the necessary details about file inside zip
+
+ buf = (void*)malloc(size_buf); // setup buffer
+ if (buf == NULL) {
+ SETTING_TRACE("Error allocating memory for read buffer");
+ return -1;
+ } // buffer ready
+
+ err = unzOpenCurrentFilePassword(uf,NULL); // Open the file inside the zip (password = NULL)
+ if (err != UNZ_OK) {
+ SETTING_TRACE("Error %d with zipfile %s in unzOpenCurrentFilePassword.", err, zipFile);
+ return -1;
+ } // file inside the zip is open
+
+ snprintf(tempfilename,256, "%s/%s", UNCOMPRESSEDFILE_DIR, fileInZip);
+
+ tempfile_fp = fopen(tempfilename,"w");
+ if (tempfile_fp == NULL) {
+ SETTING_TRACE("Error to write tempfile : %s", tempfilename);
+ return -1;
+ } // open temp file
+
+ // Copy contents of the file inside the zip to the buffer
+ printf("Extracting: %s from %s\n", filename_inzip, zipFile);
+ do {
+ err = unzReadCurrentFile(uf,buf,size_buf);
+ if (err < 0) {
+ SETTING_TRACE("Error %d with zipfile %s in unzReadCurrentFile", err, zipFile);
+ break;
+ }
+ // copy the buffer to a string
+ if (err > 0) {
+ //for (int i = 0; i < (int) err; i++)
+ //sout.push_back( *(((char*)buf)+i) );
+ fwrite(buf, sizeof(char), err, tempfile_fp);
+ }
+ } while (err > 0);
+
+ err = unzCloseCurrentFile (uf); // close the zipfile
+ if (err!=UNZ_OK) {
+ SETTING_TRACE("Error %d with zipfile %s in unzCloseCurrentFile", err, zipFile);
}
+
+ free(buf); // free up buffer memory
+
+ fclose(tempfile_fp); // close temp file
+
+ return 0;
}
+#endif
+
+
+
static void __main_license_clicked(void *data)
{
SETTING_TRACE_BEGIN;
int ret;
SettingLicenseData *ad = (SettingLicenseData *)data;
app_control_h svc = NULL;
+#if SUPPORT_COMPRESSED_LICENSE
+ char tempfilename[256]; // for temp file
+#endif
ret_if(app_control_create(&svc) != 0);
+
+
+#if SUPPORT_COMPRESSED_LICENSE
+ ret = readZipFile("/usr/share/license.zip", "license.html");
+ if(ret != 0){
+ app_control_destroy(svc);
+ return;
+ }
+
+ // set path of license.html
+ snprintf(tempfilename,256, "file://%s/license.html", UNCOMPRESSEDFILE_DIR);
+ app_control_add_extra_data(svc, "file", tempfilename);
+#else
app_control_add_extra_data(svc, "file",
SETTING_OPEN_SOURCE_LICENSE_PATH);
+#endif
+
app_control_add_extra_data(svc, "title",
_("IDS_ST_BODY_OPEN_SOURCE_LICENCES"));
ret = app_launcher_svc("org.tizen.setting-fileview", svc,
_app_reply_cb, (void *)ad);
- if (ret != 0)
+ if (ret != 0) {
setting_create_popup(ad, ad->md.window, NULL,
- _(UNSUPPORTED_FUNCTION), NULL, 0, false, false,
- 0);
+ _(UNSUPPORTED_FUNCTION), NULL, 0, false, false, 0);
+ }
app_control_destroy(svc);
+
}
static void __mouse_up_Gendial_list_cb(void *data,