[Title] added log path to detail info dialog
authorgiwoong.kim <giwoong.kim@samsung.com>
Fri, 15 Jun 2012 04:55:20 +0000 (13:55 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Fri, 15 Jun 2012 04:55:20 +0000 (13:55 +0900)
[Type] enhancement
[Module] Emulator / skin
[Priority] minor
[Jira#]
[Redmine#]
[Problem]
[Cause] usability
[Solution] show log paht information
[TestCase]

tizen/src/debug_ch.c
tizen/src/debug_ch.h
tizen/src/skin/client/src/org/tizen/emulator/skin/dialog/DetailInfoDialog.java
tizen/src/skin/maruskin_operation.c [changed mode: 0644->0755]

index 7c2e372b192c6e014df21c960de2c9b3fd6c89eb..32da4ecdf8b8078938488a427dd8c80cea72fe08 100644 (file)
@@ -57,6 +57,11 @@ void set_log_path(char *path)
     strcpy(logpath, path);
 }
 
+char *get_log_path(void)
+{
+    return logpath;
+}
+
 static inline int interlocked_xchg_add( int *dest, int incr )
 {
        int ret;
index 298b7c5bf9e855f008dbf177320858be336e158d..71411b39fae7cdedfbb071297b2ab65eea2c0f7d 100644 (file)
@@ -58,6 +58,7 @@ struct _debug_channel
 };
 
 void set_log_path(char *path);
+char *get_log_path(void);
 
 #ifndef NO_DEBUG
 #define MSGSIZE_MAX 2048
index be8d2bd3fca3411e26fc4e0378f6a219e9cc0ebe..b01d402384b3e335719f7339f69d4ef2b0e38a49 100644 (file)
 
 package org.tizen.emulator.skin.dialog;
 
+import java.io.File;
+import java.io.IOException;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map.Entry;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Button;
@@ -66,6 +70,8 @@ public class DetailInfoDialog extends SkinDialog {
 
        private SocketCommunicator communicator;
        private EmulatorConfig config;
+       private Table table;
+       private LinkedHashMap<String, String> refinedData;
 
        public DetailInfoDialog( Shell parent, String emulatorName, SocketCommunicator communicator, EmulatorConfig config ) {
                super( parent, "Detail Info" + " - " + emulatorName, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE
@@ -85,7 +91,7 @@ public class DetailInfoDialog extends SkinDialog {
                Composite composite = new Composite( parent, SWT.NONE );
                composite.setLayout( new FillLayout() );
 
-               Table table = new Table( composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION );
+               table = new Table( composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION );
                table.setHeaderVisible( true );
                table.setLinesVisible( true );
 
@@ -99,7 +105,7 @@ public class DetailInfoDialog extends SkinDialog {
 
                int index = 0;
 
-               LinkedHashMap<String, String> refinedData = composeAndParseData( infoData );
+               refinedData = composeAndParseData( infoData );
                Iterator<Entry<String, String>> iterator = refinedData.entrySet().iterator();
 
                while ( iterator.hasNext() ) {
@@ -114,9 +120,48 @@ public class DetailInfoDialog extends SkinDialog {
 
                column[0].pack();
                column[1].pack();
-
                table.pack();
 
+               /* browse the log path when log path item is selected */
+               table.addSelectionListener(new SelectionListener() {
+                       @Override
+                       public void widgetSelected(SelectionEvent event) {
+                               //do nothing
+                       }
+
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent event) {
+                               if (table.getSelectionCount() > 1) {
+                                       return;
+                               }
+
+                               TableItem tableItem = ((TableItem)table.getSelection()[0]);
+                               final String logKey = "Log Path";
+
+                               if (tableItem.getText().compareTo(logKey) == 0) {
+                                       String logPath = refinedData.get(logKey);
+                                       ProcessBuilder procBrowser = new ProcessBuilder();
+
+                                       if (SkinUtil.isLinuxPlatform()) {
+                                               procBrowser.command("nautilus", "--browser", logPath);
+                                       } else if (SkinUtil.isWindowsPlatform()) {
+                                               procBrowser.command("explorer", "\"" + logPath + "\"");
+                                       } else if (SkinUtil.isMacPlatform()) {
+                                               //TODO:
+                                       }
+
+                                       if (procBrowser.command().isEmpty() == false) {
+                                               try {
+                                                       procBrowser.start();
+                                               } catch (Exception e) {
+                                                       logger.log( Level.SEVERE, e.getMessage(), e);
+                                               }
+                                       }
+                               }
+
+                       }
+               });
+
                return composite;
 
        }
@@ -124,9 +169,9 @@ public class DetailInfoDialog extends SkinDialog {
        @Override
        protected void setShellSize() {
                if( SkinUtil.isLinuxPlatform() ) {
-                       shell.setSize( (int) ( 380 * 1.618 ), 380 );
-               }else {
-                       shell.setSize( (int) ( 350 * 1.618 ), 350 );
+                       shell.setSize( (int) ( 402 * 1.618 ), 402 );
+               } else {
+                       shell.setSize( (int) ( 372 * 1.618 ), 372 );
                }
        }
 
@@ -161,7 +206,7 @@ public class DetailInfoDialog extends SkinDialog {
                String sharedPath = "";
                boolean isHwVirtual = false;
                String hwVirtualCompare = "";
-               String haxError = "hax_error=";
+               String logPath = "";
                boolean isHaxError = false;
                
                if ( SkinUtil.isLinuxPlatform() ) {
@@ -252,11 +297,20 @@ public class DetailInfoDialog extends SkinDialog {
 
                                        } else if ( hwVirtualCompare.equals( arg ) ) {
                                                isHwVirtual = true;
-                                       } else if ( arg.startsWith( haxError ) ) {
+                                       } else if ( arg.startsWith("hax_error=") ) {
                                                String[] sp = arg.split( "=" );
                                                if( 1 < sp.length ) {
                                                        isHaxError = Boolean.parseBoolean( sp[1] );
                                                }
+                                       } else if (arg.startsWith("log_path=")) {
+                                               String[] sp = arg.split("=");
+                                               if( 1 < sp.length ) {
+                                                       final String logSuffix = "/logs/";
+
+                                                       logPath = sp[1];
+                                                       logPath = logPath.substring(0, logPath.lastIndexOf(logSuffix) + logSuffix.length());
+                                                       logger.info("log path = " + logPath); //without filename
+                                               }
                                        }
 
                                }
@@ -285,7 +339,7 @@ public class DetailInfoDialog extends SkinDialog {
 
                result.put( "RAM Size", ram );
 
-               if( SkinUtil.isLinuxPlatform() ) {
+               if ( SkinUtil.isLinuxPlatform() ) {
                        if ( StringUtil.isEmpty( sharedPath ) ) {
                                result.put( "File Sharing", "Not Supported" );
                                result.put( "File Shared Path", "None" );
@@ -295,7 +349,7 @@ public class DetailInfoDialog extends SkinDialog {
                        }
                }
 
-               if( isHwVirtual ) {
+               if ( isHwVirtual ) {
                        if( isHaxError ) {
                                result.put( "HW Virtualization State", "Disable(insufficient memory for driver)" );
                        }else {
@@ -311,6 +365,17 @@ public class DetailInfoDialog extends SkinDialog {
                        result.put( "Image Path", imagePath );                  
                }
 
+               if (logPath.isEmpty() == false) {
+                       File logFile = new File(logPath);
+                       try {
+                               logPath = logFile.getCanonicalPath();
+                       } catch (IOException e) {
+                               logger.log(Level.SEVERE, e.getMessage(), e);
+                       }
+
+                       result.put("Log Path", logPath);
+               }
+
                return result;
 
        }
old mode 100644 (file)
new mode 100755 (executable)
index 7a0ce1a..3d60e28
@@ -281,12 +281,14 @@ DetailInfo* get_detail_info( int qemu_argc, char** qemu_argv ) {
     int total_len = 0;
     int delimiter_len = strlen( DATA_DELIMITER );
 
+    /* collect QEMU information */
     for ( i = 0; i < qemu_argc; i++ ) {
         total_len += strlen( qemu_argv[i] );
         total_len += delimiter_len;
     }
 
 #ifdef _WIN32
+    /* collect HAXM information */
     const int HAX_LEN = 32;
     char hax_error[HAX_LEN];
     memset( hax_error, 0, HAX_LEN );
@@ -300,10 +302,17 @@ DetailInfo* get_detail_info( int qemu_argc, char** qemu_argv ) {
             error = 1;
         }
     }
-    hax_err_len += sprintf( hax_error + hax_err_len, "%s", error ? "true" : "false" );
-    total_len += hax_err_len;
+    hax_err_len += sprintf( hax_error + hax_err_len, "%s#", error ? "true" : "false" );
+    total_len += (hax_err_len + 1);
 #endif
 
+    /* collect log path information */
+#define LOGPATH_TEXT "log_path="
+    char* log_path = get_log_path();
+    int log_path_len = strlen(LOGPATH_TEXT) + strlen(log_path) + delimiter_len;
+    total_len += (log_path_len + 1);
+
+    /* memory allocation */
     char* info_data = g_malloc0( total_len + 1 );
     if ( !info_data ) {
         g_free( detail_info );
@@ -311,8 +320,10 @@ DetailInfo* get_detail_info( int qemu_argc, char** qemu_argv ) {
         return NULL;
     }
 
+
+    /* write informations */
     int len = 0;
-    total_len = 0;
+    total_len = 0; //recycle
 
     for ( i = 0; i < qemu_argc; i++ ) {
         len = strlen( qemu_argv[i] );
@@ -321,10 +332,13 @@ DetailInfo* get_detail_info( int qemu_argc, char** qemu_argv ) {
     }
 
 #ifdef _WIN32
-    snprintf( info_data + total_len, total_len + 1, "%s", hax_error );
+    snprintf( info_data + total_len, hax_err_len + 1, "%s#", hax_error );
     total_len += hax_err_len;
 #endif
 
+    snprintf( info_data + total_len, log_path_len + 1, "%s%s#", LOGPATH_TEXT, log_path );
+    total_len += log_path_len;
+
     INFO( "################## detail info data ####################\n" );
     INFO( "%s\n", info_data );
 
@@ -332,7 +346,6 @@ DetailInfo* get_detail_info( int qemu_argc, char** qemu_argv ) {
     detail_info->data_length = total_len;
 
     return detail_info;
-
 }
 
 void free_detail_info( DetailInfo* detail_info ) {
@@ -345,6 +358,7 @@ void free_detail_info( DetailInfo* detail_info ) {
 }
 
 void open_shell( void ) {
+    INFO("open shell\n");
 }
 
 void onoff_usb_kbd( int on )