private void processIntent(Intent intent) { // get either session instance or create one from a bookmark Bundle bundle = intent.getExtras(); if (bundle.containsKey(PARAM_INSTANCE)) { int inst = bundle.getInt(PARAM_INSTANCE); session = GlobalApp.getSession(inst); bitmap = session.getSurface().getBitmap(); bindSession(); } else if (bundle.containsKey(PARAM_CONNECTION_REFERENCE)) { BookmarkBase bookmark = null; String refStr = bundle.getString(PARAM_CONNECTION_REFERENCE); if (ConnectionReference.isHostnameReference(refStr)) { bookmark = new ManualBookmark(); bookmark.<ManualBookmark>get().setHostname(ConnectionReference.getHostname(refStr)); } else if (ConnectionReference.isBookmarkReference(refStr)) { if (ConnectionReference.isManualBookmarkReference(refStr)) bookmark = GlobalApp.getManualBookmarkGateway() .findById(ConnectionReference.getManualBookmarkId(refStr)); else assert false; } if (bookmark != null) connect(bookmark); else closeSessionActivity(RESULT_CANCELED); } else { // no session found - exit closeSessionActivity(RESULT_CANCELED); } }
private void OnConnectionSuccess(Context context) { Log.v(TAG, "OnConnectionSuccess"); // bind session bindSession(); if (progressDialog != null) { progressDialog.dismiss(); progressDialog = null; } // add hostname to history if quick connect was used Bundle bundle = getIntent().getExtras(); if (bundle != null && bundle.containsKey(PARAM_CONNECTION_REFERENCE)) { if (ConnectionReference.isHostnameReference(bundle.getString(PARAM_CONNECTION_REFERENCE))) { assert session.getBookmark().getType() == BookmarkBase.TYPE_MANUAL; String item = session.getBookmark().<ManualBookmark>get().getHostname(); if (!GlobalApp.getQuickConnectHistoryGateway().historyItemExists(item)) GlobalApp.getQuickConnectHistoryGateway().addHistoryItem(item); } } }
private void connect(BookmarkBase bookmark) { session = GlobalApp.createSession(bookmark); session.setUIEventListener(this); // set writeable data directory LibFreeRDP.setDataDirectory(session.getInstance(), getFilesDir().toString()); BookmarkBase.ScreenSettings screenSettings = session.getBookmark().getActiveScreenSettings(); Log.v(TAG, "Screen Resolution: " + screenSettings.getResolutionString()); if (screenSettings.isAutomatic()) { if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) { // large screen device i.e. tablet: simply use screen info screenSettings.setHeight(screen_height); screenSettings.setWidth(screen_width); } else { // small screen device i.e. phone: // Automatic uses the largest side length of the screen and makes a 16:10 resolution setting // out of it int screenMax = (screen_width > screen_height) ? screen_width : screen_height; screenSettings.setHeight(screenMax); screenSettings.setWidth((int) ((float) screenMax * 1.6f)); } } progressDialog = new ProgressDialog(this); progressDialog.setTitle(bookmark.getLabel()); progressDialog.setMessage(getResources().getText(R.string.dlg_msg_connecting)); progressDialog.setButton( ProgressDialog.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { connectCancelledByUser = true; LibFreeRDP.cancelConnection(session.getInstance()); } }); progressDialog.setCancelable(false); progressDialog.show(); Thread thread = new Thread( new Runnable() { public void run() { session.connect(); } }); thread.start(); }