connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/registry/Registry.java
changeset 699 fe13162b76cf
parent 698 9162f4cfad65
child 700 9441b6037cb6
equal deleted inserted replaced
698:9162f4cfad65 699:fe13162b76cf
   248 				Messages.getString("Registry.ConnectedServiceFactoryError"), //$NON-NLS-1$
   248 				Messages.getString("Registry.ConnectedServiceFactoryError"), //$NON-NLS-1$
   249 				service.getDisplayName(), connection.getConnectionType().getDisplayName()), null);
   249 				service.getDisplayName(), connection.getConnectionType().getDisplayName()), null);
   250 		return null;
   250 		return null;
   251 	}
   251 	}
   252 
   252 
   253 	/* (non-Javadoc)
       
   254 	 * @see com.nokia.carbide.remoteconnections.registry.IConnectionStore#storeConnections()
       
   255 	 */
       
   256 	public void storeConnections() {
   253 	public void storeConnections() {
   257 		try {
   254 		try {
   258 			OutputStream os = new FileOutputStream(getConnectionStorageFile());
   255 			OutputStream os = new FileOutputStream(getConnectionStorageFile());
   259 			Writer.writeToXML(os, connectionToConnectedServices.keySet());
   256 			Writer.writeToXML(os, getNonDynamicConnections());
   260 		} 
   257 		} 
   261 		catch (Exception e) {
   258 		catch (Exception e) {
   262 			RemoteConnectionsActivator.log(Messages.getString("Registry.ConnectionStoreError"), e); //$NON-NLS-1$
   259 			RemoteConnectionsActivator.log(Messages.getString("Registry.ConnectionStoreError"), e); //$NON-NLS-1$
   263 		}
   260 		}
   264 	}
   261 	}
   265 	
   262 	
       
   263 	private Collection<IConnection> getNonDynamicConnections() {
       
   264 		List<IConnection> nonDynamicConnections = new ArrayList<IConnection>();
       
   265 		for (IConnection connection : connectionToConnectedServices.keySet()) {
       
   266 			if (!(connection instanceof IConnection2) ||
       
   267 					!((IConnection2) connection).isDynamic())
       
   268 				nonDynamicConnections.add(connection);
       
   269 		}
       
   270 		return nonDynamicConnections;
       
   271 	}
       
   272 
   266 	public void addConnectionStoreChangedListener(IConnectionsManagerListener listener) {
   273 	public void addConnectionStoreChangedListener(IConnectionsManagerListener listener) {
   267 		if (listeners == null)
   274 		if (listeners == null)
   268 			listeners = new ListenerList<IConnectionsManagerListener>();
   275 			listeners = new ListenerList<IConnectionsManagerListener>();
   269 		listeners.add(listener);
   276 		listeners.add(listener);
   270 	}
   277 	}
   520 			fireDefaultConnectionSet(connection);
   527 			fireDefaultConnectionSet(connection);
   521 		}
   528 		}
   522 	}
   529 	}
   523 
   530 
   524 	public IConnection getDefaultConnection() {
   531 	public IConnection getDefaultConnection() {
       
   532 		if (defaultConnection == null)
       
   533 			pickNewDefaultConnection();
   525 		return defaultConnection;
   534 		return defaultConnection;
   526 	}
   535 	}
   527 
   536 
   528 	public void disconnect(IConnection connection) {
   537 	public void disconnect(IConnection connection) {
   529 		// TODO transition to disconnected state and wait:
   538 		// TODO transition to disconnected state and wait: