diff options
author | kh5325.kim <kh5325.kim@samsung.com> | 2013-10-24 17:07:13 +0900 |
---|---|---|
committer | kh5325.kim <kh5325.kim@samsung.com> | 2013-10-24 17:07:13 +0900 |
commit | 70d0c4a5f2efe9a45a71167204a31bb9536c37aa (patch) | |
tree | 9fd350a432be579cc6b1d953a843c52e6f084043 | |
parent | 2a827330141271b90ac7c128d9babb9c482f0b24 (diff) | |
download | common-eplugin-70d0c4a5f2efe9a45a71167204a31bb9536c37aa.tar.gz common-eplugin-70d0c4a5f2efe9a45a71167204a31bb9536c37aa.tar.bz2 common-eplugin-70d0c4a5f2efe9a45a71167204a31bb9536c37aa.zip |
Upload tizen_2.2 source
Change-Id: I3421347c73da03100bb0e5a76ce649fa581634b0
18 files changed, 468 insertions, 114 deletions
diff --git a/org.tizen.common.builder/src/org/tizen/common/builder/BuildProcess.java b/org.tizen.common.builder/src/org/tizen/common/builder/BuildProcess.java index eff178cc5..134eb2bdf 100755 --- a/org.tizen.common.builder/src/org/tizen/common/builder/BuildProcess.java +++ b/org.tizen.common.builder/src/org/tizen/common/builder/BuildProcess.java @@ -206,7 +206,7 @@ public class BuildProcess try
{
// Step#1 Remove dependency tree about resources what will be built
- final Collection<Resource> projectedResources = new HashSet<Resource>();
+ final Collection<Resource> projectedResources = new ArrayList<Resource>();
for ( final Resource resource : sortedResources )
{
projectedResources.addAll( removeResource( resource ) );
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/ui/SyncProgressMonitor.java b/org.tizen.common.connection/src/org/tizen/common/connection/ui/SyncProgressMonitor.java index 6896ce2e1..f2f9ded81 100644 --- a/org.tizen.common.connection/src/org/tizen/common/connection/ui/SyncProgressMonitor.java +++ b/org.tizen.common.connection/src/org/tizen/common/connection/ui/SyncProgressMonitor.java @@ -49,6 +49,10 @@ public class SyncProgressMonitor implements ISyncProgressMonitor private String labelTo = "To: "; private String labelSize = "Size: "; + private String lastFromStr = ""; + private String lastToStr = ""; + private String lastSizeStr = ""; + protected long totalWork; protected long worked; @@ -150,12 +154,22 @@ public class SyncProgressMonitor implements ISyncProgressMonitor public void run() { monitor.worked(work); - if(!fromLabel.getText().equals(fromStr)) + + if(!lastFromStr.equals(fromStr)) + { fromLabel.setText(TransferProgressMonitorDialog.shortenText(fromStr, fromLabel)); - if(!toLabel.getText().equals(toStr)) + lastFromStr = fromStr; + } + if(!lastToStr.equals(toStr)) + { toLabel.setText(TransferProgressMonitorDialog.shortenText(toStr, toLabel)); - if(!sizeStr.contains("KB") && !sizeLabel.getText().equals(sizeStr)) + lastToStr = toStr; + } + if(!sizeStr.contains("KB") && !lastSizeStr.equals(sizeStr)) + { sizeLabel.setText(TransferProgressMonitorDialog.shortenText(sizeStr, sizeLabel)); + lastSizeStr = sizeStr; + } } }); } diff --git a/org.tizen.common.sdblib/src/org/tizen/sdblib/SdbHelper.java b/org.tizen.common.sdblib/src/org/tizen/sdblib/SdbHelper.java index fa98bd4ed..c2c5f0c14 100755 --- a/org.tizen.common.sdblib/src/org/tizen/sdblib/SdbHelper.java +++ b/org.tizen.common.sdblib/src/org/tizen/sdblib/SdbHelper.java @@ -35,6 +35,9 @@ import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.channels.SocketChannel; import java.nio.charset.Charset; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.atomic.AtomicBoolean; import org.tizen.sdblib.exception.SdbCommandRejectedException; import org.tizen.sdblib.exception.TimeoutException; @@ -396,58 +399,75 @@ public class SdbHelper { * @param chan the opened socket to write to. * @param data the buffer to send. * - * @throws TimeoutException in case of timeout on the connection. - * @throws IOException in case of I/O error on the connection. + * @throws IOException if writing is failed */ - public static void write(SocketChannel chan, byte[] data) throws TimeoutException, IOException { + public static + void + write( + final SocketChannel chan, + final byte[] data + ) + throws IOException + { write(chan, data, -1, Preferences.getTimeOut()); } /** * write {@code data} untim time out * - * @param chan the opened socket to write to. - * @param data the buffer to send. - * @param length the length to write or -1 to send the whole buffer. - * @param timeout The timeout value. A timeout of zero means "wait forever". + * @param chan {@link SocketChannel} to write. + * @param data data in byte[]. + * @param length the length to write. + * @param timeout timeout to wait. * - * @throws TimeoutException in case of timeout on the connection. - * @throws IOException in case of I/O error on the connection. + * @throws IOException if writing is failed */ - public static void write( + public static + void + write( final SocketChannel chan, final byte[] data, final int length, final int timeout ) - throws TimeoutException, IOException + throws IOException { - ByteBuffer buf = ByteBuffer.wrap(data, 0, length < 0 ? data.length : length ); - int numWaits = 0; - - while (buf.position() != buf.limit()) { - int count; + final ByteBuffer buf = ByteBuffer.wrap(data, 0, length < 0 ? data.length : length ); + final AtomicBoolean running = new AtomicBoolean( true ); + Timer timer = null; + if ( 0 < timeout ) { + timer = new Timer(); + timer.schedule( new TimerTask() + { + @Override + synchronized public void run() + { + running.set( false ); + } + }, timeout ); + } - count = chan.write(buf); - if (count < 0) { + while (buf.position() != buf.limit() && running.get() ) + { + int count = chan.write( buf ); + if ( count < 0 ) + { Log.d("sdb", "write: channel EOF"); throw new IOException("channel EOF"); - } else if (count == 0) { - // TODO: need more accurate timeout? - if ( 0 < timeout && numWaits * WAIT_TIME > timeout) { - Log.d("sdb", "write: timeout"); - throw new TimeoutException(); - } - // non-blocking spin - try { - Thread.sleep(WAIT_TIME); - } catch (InterruptedException ie) { - } - numWaits++; - } else { - numWaits = 0; } + else if ( 0 == count ) + { + trySleep( WAIT_TIME ); + } + } + if ( buf.position() == buf.limit() ) + { + if(timer != null) + timer.cancel(); + return ; } + Log.d("sdb", "write: Timeout"); + throw new TimeoutException(); } /** diff --git a/org.tizen.common.sdblib/src/org/tizen/sdblib/SmartDevelopmentBridge.java b/org.tizen.common.sdblib/src/org/tizen/sdblib/SmartDevelopmentBridge.java index 23bb2f375..eb641613b 100644..100755 --- a/org.tizen.common.sdblib/src/org/tizen/sdblib/SmartDevelopmentBridge.java +++ b/org.tizen.common.sdblib/src/org/tizen/sdblib/SmartDevelopmentBridge.java @@ -141,27 +141,25 @@ SmartDevelopmentBridge } /** - * Creates a new debug bridge from the location of the command line tool. + * Creates {@link SmartDevelopmentBridge} instance. * <p/> - * Any existing server will be disconnected, unless the location is the same and - * <code>forceNewBridge</code> is set to false. - * @param osLocation the location of the command line tool 'sdb' - * @param forceNewBridge force creation of a new bridge even if one with the same location - * already exists. - * @return a connected bridge. + * @param location the location of 'sdb' + * @param bForce force to create new instance + * + * @return {@link SmartDevelopmentBridge} instance */ public static SmartDevelopmentBridge createBridge( - final String osLocation, - final boolean forceNewBridge + final String location, + final boolean bForce ) { init(); synchronized (sLock) { if (instance != null) { - if (instance.mSdbOsLocation != null && instance.mSdbOsLocation.equals(osLocation) && - forceNewBridge == false) { + if (instance.mSdbOsLocation != null && instance.mSdbOsLocation.equals(location) && + bForce == false) { return instance; } else { // stop the current server @@ -169,27 +167,10 @@ SmartDevelopmentBridge } } - instance = new SmartDevelopmentBridge(osLocation); + instance = new SmartDevelopmentBridge(location); instance.start(); - - // because the listeners could remove themselves from the list while processing - // their event callback, we make a copy of the list and iterate on it instead of - // the main list. - // This mostly happens when the application quits. - IDebugBridgeChangeListener[] listenersCopy = sBridgeListeners.toArray( - new IDebugBridgeChangeListener[sBridgeListeners.size()]); - - // notify the listeners of the change - for (IDebugBridgeChangeListener listener : listenersCopy) { - // we attempt to catch any exception so that a bad listener doesn't kill our - // thread - try { - listener.bridgeChanged(instance); - } catch (Exception e) { - Log.e(TAG_SDBLIB, e); - } - } - + + fireBridgetChanged( instance ); return instance; } } @@ -204,6 +185,29 @@ SmartDevelopmentBridge public String getSdbOsLocation() { return mSdbOsLocation; } + + /** + * Fire bridge change event to {@link #sBridgeListeners} + * + */ + protected static + void + fireBridgetChanged( final SmartDevelopmentBridge instance ) + { + for ( final IDebugBridgeChangeListener listener : sBridgeListeners.toArray( new IDebugBridgeChangeListener[0] ) ) + { + try + { + listener.bridgeChanged( instance ); + } + catch ( final Exception e ) + { + Log.e( TAG_SDBLIB, e ); + } + } + + + } /** * disconnect from sdb @@ -214,19 +218,7 @@ SmartDevelopmentBridge instance.stop(); instance = null; - IDebugBridgeChangeListener[] listenersCopy = sBridgeListeners.toArray( - new IDebugBridgeChangeListener[sBridgeListeners.size()]); - - // notify the listeners. - for (IDebugBridgeChangeListener listener : listenersCopy) { - // we attempt to catch any exception so that a bad listener doesn't kill our - // thread - try { - listener.bridgeChanged(instance); - } catch (Exception e) { - Log.e(TAG_SDBLIB, e); - } - } + fireBridgetChanged( null ); } } } @@ -539,10 +531,15 @@ SmartDevelopmentBridge /** * Starts the sdb host side server. + * * @return true if success */ - synchronized boolean startSdb() { - if (mSdbOsLocation == null) { + synchronized + boolean + startSdb() + { + if (mSdbOsLocation == null) + { Log.e(TAG_SDB, "Cannot start sdb when SmartDevelopmentBridge is created without the location of sdb."); //$NON-NLS-1$ return false; @@ -572,10 +569,8 @@ SmartDevelopmentBridge return true; } catch (IOException ioe) { Log.d(TAG_SDBLIB, "unable to run 'sdb': " + ioe.getMessage()); //$NON-NLS-1$ - // we'll return false; } catch (InterruptedException ie) { Log.d(TAG_SDBLIB, "unable to run 'sdb': " + ie.getMessage()); //$NON-NLS-1$ - // we'll return false; } return false; @@ -602,6 +597,13 @@ SmartDevelopmentBridge command[1] = "kill-server"; //$NON-NLS-1$ proc = Runtime.getRuntime().exec(command); status = proc.waitFor(); + + if ( 0 == status ) + { + Log.d(TAG_SDBLIB, "'sdb kill-server' succeeded"); //$NON-NLS-1$ + setStarted(false); + return true; + } } catch (IOException ioe) { // we'll return false; @@ -611,21 +613,16 @@ SmartDevelopmentBridge // we'll return false; } - if (status != 0) { - Log.w(TAG_SDBLIB, - "'sdb kill-server' failed -- run manually if necessary"); //$NON-NLS-1$ - return false; - } + Log.w(TAG_SDBLIB, + "'sdb kill-server' failed -- run manually if necessary"); //$NON-NLS-1$ + return false; - Log.d(TAG_SDBLIB, "'sdb kill-server' succeeded"); //$NON-NLS-1$ - setStarted(false); - return true; } /** - * Get the stderr outputs + * Get and return the stderr outputs * - * @param process The process to get the ouput from + * @param process The process to get the stderr from * * @return contents of error stream( stderr ) * diff --git a/org.tizen.common.sdblib/src/org/tizen/sdblib/service/FileEntryInputStream.java b/org.tizen.common.sdblib/src/org/tizen/sdblib/service/FileEntryInputStream.java index ae9c2cc4f..f739c1dcd 100644 --- a/org.tizen.common.sdblib/src/org/tizen/sdblib/service/FileEntryInputStream.java +++ b/org.tizen.common.sdblib/src/org/tizen/sdblib/service/FileEntryInputStream.java @@ -33,6 +33,7 @@ import static org.tizen.sdblib.SdbHelper.string2bytes; import static org.tizen.sdblib.SdbHelper.write;
import static org.tizen.sdblib.SmartDevelopmentBridgetConstants.ID_DATA;
import static org.tizen.sdblib.SmartDevelopmentBridgetConstants.ID_DONE;
+import static org.tizen.sdblib.SmartDevelopmentBridgetConstants.ID_QUIT;
import static org.tizen.sdblib.SmartDevelopmentBridgetConstants.ID_RECV;
import static org.tizen.sdblib.service.FileEntryConstants.REMOTE_PATH_MAX_LENGTH;
import static org.tizen.sdblib.service.FileEntryConstants.SYNC_DATA_MAX;
@@ -55,6 +56,7 @@ import org.tizen.sdblib.SdbResponse; import org.tizen.sdblib.SmartDevelopmentBridge;
import org.tizen.sdblib.exception.SyncException;
import org.tizen.sdblib.exception.TimeoutException;
+import org.tizen.sdblib.util.IOUtil;
import org.tizen.sdblib.util.Log;
/**
@@ -245,5 +247,38 @@ extends InputStream return 0xFF & data[index++];
}
+ /**
+ * Create a command with a code and an int values
+ * @param command
+ * @param value
+ * @return
+ */
+ private static
+ byte[]
+ createReq(
+ final byte[] command,
+ final int value
+ )
+ {
+ final byte[] array = new byte[8];
+
+ System.arraycopy(command, 0, array, 0, 4);
+ toBytes(value, array, 4);
+
+ return array;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.io.InputStream#close()
+ */
+ @Override
+ public void close() throws IOException
+ {
+ SdbHelper.write(channel, createReq(ID_QUIT, 0));
+ IOUtil.tryClose(channel);
+ super.close();
+ }
+
}
diff --git a/org.tizen.common.sdblib/test/src/org/tizen/sdblib/SdbHelperTest.java b/org.tizen.common.sdblib/test/src/org/tizen/sdblib/SdbHelperTest.java index 0cf5199a7..4db2b4bf5 100755 --- a/org.tizen.common.sdblib/test/src/org/tizen/sdblib/SdbHelperTest.java +++ b/org.tizen.common.sdblib/test/src/org/tizen/sdblib/SdbHelperTest.java @@ -28,12 +28,17 @@ package org.tizen.sdblib; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.any; import static org.powermock.api.mockito.PowerMockito.mock; import static org.powermock.api.mockito.PowerMockito.when; import static org.tizen.sdblib.SdbHelper.check; import static org.tizen.sdblib.SdbHelper.read; import static org.tizen.sdblib.SdbHelper.readAsString; +import static org.tizen.sdblib.SdbHelper.write; +import static org.tizen.sdblib.util.ThreadUtil.trySleep; +import java.io.ByteArrayOutputStream; import java.nio.ByteBuffer; import java.nio.channels.SocketChannel; @@ -41,8 +46,10 @@ import org.junit.Test; import org.mockito.Matchers; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import org.tizen.sdblib.exception.TimeoutException; -public class SdbHelperTest +public class +SdbHelperTest { @Test @@ -110,5 +117,70 @@ public class SdbHelperTest assertEquals( "HELO", readAsString( channel, buffer ) ); } + @Test + public + void + test_write() + throws Exception + { + { + final SocketChannel channel = mock( SocketChannel.class ); + final byte[] buffer = "Hello, world".getBytes(); + final ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); + when( channel.write( any( ByteBuffer.class ) ) ).then( new Answer<Integer>() + { + + @Override + public Integer answer(InvocationOnMock invocation) throws Throwable + { + final ByteBuffer b = (ByteBuffer) invocation.getArguments()[0]; + int i = 0; + while( i<2 && 0 < b.remaining() ) { + byteOut.write( b.get() ); + ++i; + } + return i; + } + } ); + write( channel, buffer, -1, 1000 ); + + assertArrayEquals( "Hello, world".getBytes(), byteOut.toByteArray() ); + } + + { + final SocketChannel channel = mock( SocketChannel.class ); + final byte[] buffer = "Hello, world".getBytes(); + final ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); + when( channel.write( any( ByteBuffer.class ) ) ).then( new Answer<Integer>() + { + + @Override + public + Integer + answer( final InvocationOnMock invocation + ) throws Throwable + { + final ByteBuffer b = (ByteBuffer) invocation.getArguments()[0]; + int i = 0; + while( i<2 && 0 < b.remaining() ) { + byteOut.write( b.get() ); + ++i; + } + trySleep( 300 ); + return i; + } + } ); + try + { + write( channel, buffer, -1, 1000 ); + fail(); + } + catch ( final TimeoutException e ) + { + } + + } + + } } diff --git a/org.tizen.common.sign/META-INF/MANIFEST.MF b/org.tizen.common.sign/META-INF/MANIFEST.MF index f7b3311a5..483634bcc 100644 --- a/org.tizen.common.sign/META-INF/MANIFEST.MF +++ b/org.tizen.common.sign/META-INF/MANIFEST.MF @@ -10,7 +10,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.help Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Import-Package: org.eclipse.core.resources +Import-Package: org.eclipse.core.resources, + org.eclipse.ui.actions Bundle-Vendor: %Bundle-Vendor Export-Package: hashsign, org.tizen.common.sign, diff --git a/org.tizen.common.sign/src/org/tizen/common/sign/preferences/SigningPreferencePage.java b/org.tizen.common.sign/src/org/tizen/common/sign/preferences/SigningPreferencePage.java index a9cbaf817..d0343a969 100755 --- a/org.tizen.common.sign/src/org/tizen/common/sign/preferences/SigningPreferencePage.java +++ b/org.tizen.common.sign/src/org/tizen/common/sign/preferences/SigningPreferencePage.java @@ -30,13 +30,21 @@ import static org.tizen.common.util.StringUtil.EMPTY_STRING; import static org.tizen.common.util.StringUtil.isEmpty; import static org.tizen.common.util.StringUtil.trim; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.File; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; import keycertificategenerator.TizenKeyCertificateGenerator; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -48,6 +56,7 @@ import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IInputValidator; import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.resource.JFaceResources; @@ -80,6 +89,7 @@ import org.eclipse.swt.widgets.TableColumn; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.WorkspaceModifyOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.tizen.common.TizenHelpContextIds; @@ -92,8 +102,12 @@ import org.tizen.common.sign.ui.CertGenerationDialog.CertDataKey; import org.tizen.common.sign.util.SigningPathUtil; import org.tizen.common.sign.util.SigningProfileUtil; import org.tizen.common.ui.dialog.FileDialogUtils; +import org.tizen.common.util.DialogUtil; import org.tizen.common.util.FileUtil; import org.tizen.common.util.ObjectUtil; +import org.tizen.common.util.ProjectUtil; +import org.tizen.common.util.SWTUtil; +import org.tizen.common.util.StringUtil; public class SigningPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { @@ -108,9 +122,10 @@ public class SigningPreferencePage extends PreferencePage implements IWorkbenchP protected TableViewer distributorTableViewer; protected List<Button> profileDependsButtons; - + protected List<Button> profilesEnableButton; protected SigningProfileContainer container; + protected SigningProfileContainer loadedContainer; // for modified check /** @@ -118,6 +133,7 @@ public class SigningPreferencePage extends PreferencePage implements IWorkbenchP */ public SigningPreferencePage() { profileDependsButtons = new ArrayList<Button>(); + profilesEnableButton = new ArrayList<Button>(); } /** @@ -135,6 +151,7 @@ public class SigningPreferencePage extends PreferencePage implements IWorkbenchP // load profile this.container = SigningProfileUtil.getProfileContainerFromFile(); + this.loadedContainer = SigningProfileUtil.getProfileContainerFromFile(); // create root composite Composite composite = createComposite( @@ -285,6 +302,7 @@ public class SigningPreferencePage extends PreferencePage implements IWorkbenchP String activeProfileName = SigningProfileUtil.getActiveProfileName(); SigningProfile activeProfile = this.container.getProfileByName( activeProfileName ); this.container.setActiveProfile( activeProfile ); + this.loadedContainer.setActiveProfile( activeProfile ); // TODO: ???? this.listViewer.setInput( "profile" ); @@ -388,6 +406,10 @@ public class SigningPreferencePage extends PreferencePage implements IWorkbenchP // validate page validatePreferencePage(); + + for ( Button button : profilesEnableButton ) { + button.setEnabled( true ); + } } } @@ -426,6 +448,7 @@ public class SigningPreferencePage extends PreferencePage implements IWorkbenchP @Override public void widgetDefaultSelected(SelectionEvent e) {} }); + profilesEnableButton.add( modifyProfilesButton ); // 'set active' button Button defaultProfileButton = new Button( profileButtonComposite, SWT.NONE ); @@ -447,6 +470,7 @@ public class SigningPreferencePage extends PreferencePage implements IWorkbenchP @Override public void widgetDefaultSelected(SelectionEvent e) {} }); + profilesEnableButton.add( defaultProfileButton ); // 'remove' button final Button removeProfileButton = new Button( profileButtonComposite, SWT.NONE ); @@ -477,11 +501,23 @@ public class SigningPreferencePage extends PreferencePage implements IWorkbenchP validatePreferencePage(); } + + if ( container.getProfiles().isEmpty() ) { + for ( Button button : profilesEnableButton ) { + button.setEnabled( false ); + } + } } @Override public void widgetDefaultSelected(SelectionEvent e) {} }); + profilesEnableButton.add( removeProfileButton ); + + boolean enableRelatedButton = ! container.getProfiles().isEmpty(); + for ( Button button : profilesEnableButton ) { + button.setEnabled( enableRelatedButton ); + } return profileButtonComposite; } @@ -887,8 +923,43 @@ public class SigningPreferencePage extends PreferencePage implements IWorkbenchP @Override public boolean performOk() { - SigningProfileUtil.setActiveProfileName( container.getActiveProfileName() ); - SigningProfileUtil.writeProfilesToFile( container ); + // check an active profile change + boolean bActiveChanged = false; + String newProfileName = container.getActiveProfileName(); + if ( ! StringUtil.isEmpty( newProfileName ) && + ! newProfileName.equals( loadedContainer.getActiveProfileName() ) ) { + bActiveChanged = true; + } + + // serialize for compare + ByteArrayOutputStream containerOs = new ByteArrayOutputStream(); + container.writeProfileXML( containerOs ); + ByteArrayOutputStream loadedContainerOs = new ByteArrayOutputStream(); + loadedContainer.writeProfileXML( loadedContainerOs ); + + // if information was modified + boolean bChanged = ! Arrays.equals( containerOs.toByteArray(), loadedContainerOs.toByteArray() ); + if ( bActiveChanged || bChanged ) { + // write profiles + SigningProfileUtil.setActiveProfileName( newProfileName ); + SigningProfileUtil.writeProfilesToFile( container ); + logger.trace( "Security preferences was saved" ); + + + if ( ! loadedContainer.getProfiles().isEmpty() ) { + DialogUtil.openMessageDialog( + getShell(), + UIMessages.getString( "org.tizen.common.sign.requiredclean" ) ); + } + + // update old comparable info to new info + loadedContainer.readProfileXML( new ByteArrayInputStream( containerOs.toByteArray() ) ); + SigningProfile profile = null; + if ( newProfileName != null ) { + profile = loadedContainer.getProfileByName( newProfileName ); + } + loadedContainer.setActiveProfile( profile ); + } return super.performOk(); } diff --git a/org.tizen.common.sign/src/org/tizen/common/sign/preferences/SigningProfileContainer.java b/org.tizen.common.sign/src/org/tizen/common/sign/preferences/SigningProfileContainer.java index 519651e48..09286f646 100644 --- a/org.tizen.common.sign/src/org/tizen/common/sign/preferences/SigningProfileContainer.java +++ b/org.tizen.common.sign/src/org/tizen/common/sign/preferences/SigningProfileContainer.java @@ -102,7 +102,14 @@ public class SigningProfileContainer { this.activeProfileName = defaultProfile.getProfileName(); - if ( ! this.profiles.contains( defaultProfile ) ) { + boolean bContain = false; + for ( SigningProfile profile : this.profiles ) { + if ( profile.getProfileName().equals( this.activeProfileName ) ) { + bContain = true; + break; + } + } + if ( ! bContain ) { addProfile( defaultProfile ); } } diff --git a/org.tizen.common.sign/src/org/tizen/common/sign/preferences/UIMessages.properties b/org.tizen.common.sign/src/org/tizen/common/sign/preferences/UIMessages.properties index 45139463c..5875116e7 100644 --- a/org.tizen.common.sign/src/org/tizen/common/sign/preferences/UIMessages.properties +++ b/org.tizen.common.sign/src/org/tizen/common/sign/preferences/UIMessages.properties @@ -32,3 +32,4 @@ org.tizen.common.sign.certificatevaliditymessage2=is not valid.\nThe certificate org.tizen.common.sign.certificatevaliditymessage3=and after org.tizen.common.sign.note.certificate_generator=See <a>'Certificate Generator'</a> documentation to generate an author signature. +org.tizen.common.sign.requiredclean=It is required to clean projects because profile information was changed.
\ No newline at end of file diff --git a/org.tizen.common.sign/src/org/tizen/common/sign/signer/SignatureGenerator.java b/org.tizen.common.sign/src/org/tizen/common/sign/signer/SignatureGenerator.java index c32e5caff..2c28949f9 100644 --- a/org.tizen.common.sign/src/org/tizen/common/sign/signer/SignatureGenerator.java +++ b/org.tizen.common.sign/src/org/tizen/common/sign/signer/SignatureGenerator.java @@ -36,6 +36,7 @@ import org.tizen.common.TizenPlatformConstants; import org.tizen.common.core.command.ExecutionContext; import org.tizen.common.sign.command.ReadSigningProfileFileCommand; import org.tizen.common.sign.command.SignCommand; +import org.tizen.common.sign.exception.CertificationException; import org.tizen.common.sign.model.SignatureConstants; import org.tizen.common.sign.preferences.Messages; import org.tizen.common.sign.preferences.SigningProfile; @@ -93,7 +94,18 @@ public class SignatureGenerator { new ReadSigningProfileFileCommand( SigningProfileUtil.getProfilesPath().toPortableString(), getActiveProfileName() ); - CommonPlugin.getDefault().getExecutor().execute( readProfile ); + try { + CommonPlugin.getDefault().getExecutor().execute( readProfile ); + } catch( IllegalStateException e ) { + Throwable cause = e.getCause(); + + // convert the wrapped IllegalStateException to normal exception. + if ( cause instanceof CertificationException ) { + throw new IOException( cause.getMessage(), cause ); + } + + throw e; + } profile = readProfile.getProfile(); diff --git a/org.tizen.common/src/org/tizen/common/ITizenNativeXMLStore.java b/org.tizen.common/src/org/tizen/common/ITizenNativeXMLStore.java new file mode 100644 index 000000000..202a9c6d1 --- /dev/null +++ b/org.tizen.common/src/org/tizen/common/ITizenNativeXMLStore.java @@ -0,0 +1,83 @@ +/* + * Common + * + * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Kangho Kim <kh5325.kim@samsung.com> + * Ho Namkoong <ho.namkoong@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ +package org.tizen.common; + +import java.io.File; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; + +public interface ITizenNativeXMLStore { + /** + * extension point id for implementing this interface. + */ + public static final String EXSD_STORE_EXTENSION_POINT_ID = "org.tizen.nativecommon.store"; + + /** + * Class id of NewAppXmlStore which implements this interface. + */ + public static final String EXSD_APP_XML_STORE_CLASS_ID = "org.tizen.nativecpp.misc.core.NewAppXmlStore"; + + /** + * This roles same as {@link ITizenNativeXmlStore#setProject(IProject), + * except that this is for CLI because CLI cannot use IProject. + * + * @param projectPath path of project in which xml will be stored + */ + public void setProject(String projectPath); + + /** + * Sets the project of this xml store. + * @param project - project in which xml is stored. + */ + public void setProject(IProject project); + + /** + * Parses xml files and loads. + */ + public boolean loadXml(); + + /** + * Merges app data. + * @param refAppXml - xml store app data of which is merged into this xml store. + */ + public void mergeAppData(ITizenNativeXMLStore refAppXml); + + /** + * Merges privilege data. + * @param refManifestl - xml store privilege data of which is merged into this xml store. + */ + public void mergePrivData(ITizenNativeXMLStore refManifest); + + /** + * This roles same as {@link IXMLStore#storeXml(IFile)}, + * except that this is for CLI because CLI cannt use IFile. + * + * @param files to store this xml store + * @return true if store is success, fales if not + */ + boolean storeXml(File file); +} diff --git a/org.tizen.common/src/org/tizen/common/file/StandardFileHandler.java b/org.tizen.common/src/org/tizen/common/file/StandardFileHandler.java index f439bbd8a..ae5d710fc 100755 --- a/org.tizen.common/src/org/tizen/common/file/StandardFileHandler.java +++ b/org.tizen.common/src/org/tizen/common/file/StandardFileHandler.java @@ -350,8 +350,9 @@ extends AbstractFileHandler final File file = getFile( path ); if ( !file.isFile() ) { - throw new IOException(); - } + logger.error("{} is not a file", path); + throw new IOException(path + " is not a file."); + } file.delete(); } diff --git a/org.tizen.common/src/org/tizen/common/ui/dialog/LocaleDialog.java b/org.tizen.common/src/org/tizen/common/ui/dialog/LocaleDialog.java index 5745766e0..529df4f4c 100644 --- a/org.tizen.common/src/org/tizen/common/ui/dialog/LocaleDialog.java +++ b/org.tizen.common/src/org/tizen/common/ui/dialog/LocaleDialog.java @@ -65,7 +65,7 @@ public class LocaleDialog extends SelectionStatusDialog { protected static String DEFAULT_LANG = "en-gb"; protected static final String[] WRT_LANG_LISTS = { - "ar-ae", + "ar-ae", "hy-am", "az-az", "eu-es", diff --git a/org.tizen.common/src/org/tizen/common/util/ValidationUtil.java b/org.tizen.common/src/org/tizen/common/util/ValidationUtil.java index b1e0e4b35..3ff12ea6a 100644 --- a/org.tizen.common/src/org/tizen/common/util/ValidationUtil.java +++ b/org.tizen.common/src/org/tizen/common/util/ValidationUtil.java @@ -58,7 +58,7 @@ public class ValidationUtil { private static final String REGEX_EMAIL = "[A-Za-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\\.)+[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])??"; //$NON-NLS-1$ private static final String REGEX_URL = "\\b(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"; //$NON-NLS-1$ - private static final String REGEX_VERSION = "[0-9]{1,2}\\.[0-9]{1,2}(\\.[0-9]{1,4})?"; //$NON-NLS-1$ + private static final String REGEX_VERSION = "[0-9]{1,3}\\.[0-9]{1,3}(\\.[0-9]{1,5})?"; //$NON-NLS-1$ private static final String REGEX_APPWIDGETID = "[0-9a-zA-Z]{10}\\.[0-9a-zA-Z]{1,52}\\.[0-9a-zA-Z]{1,}"; //$NON-NLS-1$ public static final String WIDGET_CONTENT_FILE_EXTENSIONS[] = { ".html", ".htm", ".xhtml", ".xht", ".svg" }; // http://www.w3.org/TR/widgets/#default-start-files @@ -146,13 +146,34 @@ public class ValidationUtil { * @return {@code true} if version is valid version */ public static boolean checkForVersion( String version ) { - if ( version == null || StringUtil.isEmpty( version ) || version.equals( "0.0" ) ) { + if ( version == null || StringUtil.isEmpty( version ) ) { return false; } Pattern pattern = Pattern.compile( REGEX_VERSION ); Matcher matcher = pattern.matcher( version ); - return matcher.matches(); + if ( matcher.matches() ) { + String[] versions = version.split("\\."); + // check version length: x.y(.z) + if ( versions.length < 3 ) { + return false; + } + // check x,y value: 0<=(x,y)<=255 + for ( int index=0; index<2; index++ ) { + int xy = Integer.parseInt(versions[index]); + if ( xy < 0 || 255 < xy ) { + return false; + } + } + // check z value: 0<=z<=65535 + int z = Integer.parseInt(versions[2]); + if ( z < 0 || 65535 < z ) { + return false; + } + return true; + } else { + return false; + } } /** diff --git a/org.tizen.common/test/src/org/tizen/common/util/ValidationUtilTest.java b/org.tizen.common/test/src/org/tizen/common/util/ValidationUtilTest.java index fc620984f..3deafd5a7 100755 --- a/org.tizen.common/test/src/org/tizen/common/util/ValidationUtilTest.java +++ b/org.tizen.common/test/src/org/tizen/common/util/ValidationUtilTest.java @@ -183,14 +183,14 @@ public class ValidationUtilTest { */ @Test public void test_checkForVersion() throws Exception { - final String[] validedVersions = { "1.0.1", "1.0.111", "1.10.111", "35.35.123", "0.0.1", "0.1" }; + final String[] validedVersions = { "1.0.1", "1.0.111", "1.10.111", "35.35.123", "0.0.1", "0.0.0", "255.255.65535" }; for ( String version : validedVersions ) { - assertTrue( ValidationUtil.checkForVersion( version ) ); + assertTrue( "Failed for \"" + version + "\"", ValidationUtil.checkForVersion( version ) ); } - final String[] invalidedVersions = { "", "0.0.0", "111.111.111111", "1", "1.0.", "0" }; + final String[] invalidedVersions = { "", "256.256.65536", "1", "1.0.", "0" }; for ( String version : invalidedVersions ) { - assertFalse( ValidationUtil.checkForVersion( version ) ); + assertFalse( "Failed for \"" + version + "\"", ValidationUtil.checkForVersion( version ) ); } } @@ -205,12 +205,12 @@ public class ValidationUtilTest { public void test_checkForDynamicBoxId() throws Exception { final String[] validedIDS = { "1wfV7ZwO6r.test.test", "1wfV7ZwO6r.test.111", "1wfV7ZwO6r.test.test2222" }; for ( String id : validedIDS ) { - assertTrue( ValidationUtil.checkForDynamicBoxId( id ) ); + assertTrue( "Failed for \"" + id + "\"", ValidationUtil.checkForDynamicBoxId( id ) ); } final String[] invalidedIDS = { "", "1wfV7ZwO6r.test.-1", "1wfV7ZwO6r.test.!test", "1wfV7ZwO6r.test.test test", "1wfV7ZwO6r.test.test!#", "1wfV7ZwO6r." }; for ( String id : invalidedIDS ) { - assertFalse( ValidationUtil.checkForDynamicBoxId( id ) ); + assertFalse( "Failed for \"" + id + "\"", ValidationUtil.checkForDynamicBoxId( id ) ); } } diff --git a/package/changelog b/package/changelog index 03059d79f..8274f839b 100644 --- a/package/changelog +++ b/package/changelog @@ -1,3 +1,22 @@ +* 2.2.22 +- Fixed bug about memory error. +- Fixed bug about pulling several files. +== taeyoung2.son <taeyoung2.son@samsung.com> 2013-10-24 16:00 +* 2.2.21 +- Modify HashSet to ArrayList +== taeyoung2.son <taeyoung2.son@samsung.com> 2013-10-23 18:14 +* 2.2.20 +- Supported creating hybrid multi app on IDE. +== taeyoung2.son <taeyoung2.son@samsung.com> 2013-10-21 17:22 +* 2.2.19 +- Fixed the change problem of security profiles +== kh5325.kim <kh5325.kim@samsung.com> 2013-10-17 +* 2.2.18 +- Fixed a bug where it takes too long to push the file which have long file name in Connection Explorer +== kh5325.kim <kh5325.kim@samsung.com> 2013-10-14 +* 2.2.17 +- Remove UTF-8 BOM +== changhyun1.lee <changhyun1.lee@samsung.com> 2013-10-10 17:57 * 2.2.16 - Refactored common tools - connection explorer, logview, remote file dialog - Added (sdb) timeout setting to Tizen preferences diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest index bed1c4508..6ef6a3fcb 100644 --- a/package/pkginfo.manifest +++ b/package/pkginfo.manifest @@ -1,4 +1,4 @@ -Version:2.2.16 +Version:2.2.22 Source:common-eplugin Maintainer:kangho kim <kh5325.kim@samsung.com>, yoonki park <yoonki.park@samsung.com>, hyunsik non <hyunsik.noh@samsung.com>, taeyoung son <taeyoung2.son@samsung.com>, gune Kim <gune.kim@samsung.com>, ho namkoong <ho.namkoong@samsung.com>, hyeongseok heo <hyeong-seok.heo@samsung.com>, gyeongseok seo <gyeongseok.seo@samsung.com>, jihoon song <jihoon80.song@samsung.com>, changhyun lee <changhyun1.lee@samsung.com>, bonyong lee <bonyong.lee@samsung.com>, shingil kang <shingil.kang@samsung.com> |