Skip to content

Commit

Permalink
Improved logging when creating conncetion shortcuts for bVNC, aRDP an…
Browse files Browse the repository at this point in the history
…d aSPICE.
  • Loading branch information
iiordanov committed Jan 16, 2023
1 parent bc80825 commit 035ee1c
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 49 deletions.
97 changes: 52 additions & 45 deletions bVNC/src/main/java/com/iiordanov/bVNC/ConnectionListActivity.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/**
* Copyright (C) 2012 Iordan Iordanov
* Copyright (C) 2009-2010 Michael A. MacDonald
*
* <p>
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* <p>
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* <p>
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
Expand All @@ -23,71 +23,74 @@
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.Intent.ShortcutIconResource;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import com.iiordanov.bVNC.*;
import com.iiordanov.freebVNC.*;
import com.iiordanov.aRDP.*;
import com.iiordanov.freeaRDP.*;
import com.iiordanov.aSPICE.*;
import com.iiordanov.freeaSPICE.*;
import com.iiordanov.CustomClientPackage.*;
import com.undatech.remoteClientUi.*;

import com.undatech.remoteClientUi.R;

/**
* @author Michael A. MacDonald
*
*/
public class ConnectionListActivity extends ListActivity {


private static final String TAG = "ConnectionListActivity";
Database database;

@Override
protected void onCreate(Bundle savedInstanceState){
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

database = new Database(this);

if (isMasterPasswordEnabled()) {
Utils.showFatalErrorMessage(this, getResources().getString(R.string.master_password_error_shortcuts_not_supported));
Utils.showFatalErrorMessage(
this, getResources().getString(R.string.master_password_error_shortcuts_not_supported));
return;
}

// Query for all people contacts using the Contacts.People convenience class.
// Put a managed wrapper around the retrieved cursor so we don't have to worry about
// requerying or closing it as the activity changes state.
Cursor mCursor = database.getReadableDatabase().query(ConnectionBean.GEN_TABLE_NAME, new String[] {
ConnectionBean.GEN_FIELD__ID,
ConnectionBean.GEN_FIELD_NICKNAME,
ConnectionBean.GEN_FIELD_USERNAME,
ConnectionBean.GEN_FIELD_ADDRESS,
ConnectionBean.GEN_FIELD_PORT,
ConnectionBean.GEN_FIELD_REPEATERID },
ConnectionBean.GEN_FIELD_KEEPPASSWORD + " <> 0", null, null, null, ConnectionBean.GEN_FIELD_NICKNAME);
Cursor mCursor = database.getReadableDatabase().query(
ConnectionBean.GEN_TABLE_NAME, new String[]{
ConnectionBean.GEN_FIELD__ID,
ConnectionBean.GEN_FIELD_NICKNAME,
ConnectionBean.GEN_FIELD_USERNAME,
ConnectionBean.GEN_FIELD_ADDRESS,
ConnectionBean.GEN_FIELD_PORT,
ConnectionBean.GEN_FIELD_REPEATERID},
ConnectionBean.GEN_FIELD_KEEPPASSWORD + " <> 0",
null,
null,
null,
ConnectionBean.GEN_FIELD_NICKNAME
);

startManagingCursor(mCursor);

// Now create a new list adapter bound to the cursor.
// SimpleListAdapter is designed for binding to a Cursor.
SimpleCursorAdapter adapter = new SimpleCursorAdapter(
this, // Context.
R.layout.connection_list,
R.layout.connection_list,
mCursor, // Pass in the cursor to bind to.
new String[] {
new String[]{
ConnectionBean.GEN_FIELD_NICKNAME,
ConnectionBean.GEN_FIELD_ADDRESS,
ConnectionBean.GEN_FIELD_PORT,
ConnectionBean.GEN_FIELD_REPEATERID }, // Array of cursor columns to bind to.
new int[] {
R.id.list_text_nickname,
R.id.list_text_address,
R.id.list_text_port,
R.id.list_text_repeater
ConnectionBean.GEN_FIELD_REPEATERID}, // Array of cursor columns to bind to.
new int[]{
R.id.list_text_nickname,
R.id.list_text_address,
R.id.list_text_port,
R.id.list_text_repeater
}); // Parallel array of which template objects to bind to those columns.

// Bind to our new adapter.
Expand All @@ -100,8 +103,8 @@ protected void onCreate(Bundle savedInstanceState){
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
ConnectionBean connection = new ConnectionBean(this);
if (connection.Gen_read(database.getReadableDatabase(), id))
{
if (connection.Gen_read(database.getReadableDatabase(), id)) {
Log.d(TAG, "Got a readable database");
// create shortcut if requested
Context context = getApplicationContext();
ShortcutIconResource icon = Intent.ShortcutIconResource.fromContext(this, R.drawable.icon);
Expand All @@ -110,24 +113,28 @@ protected void onListItemClick(ListView l, View v, int position, long id) {
} else if (Utils.isSpice(context)) {
icon = Intent.ShortcutIconResource.fromContext(this, R.drawable.icon_aspice);
}

Intent intent = new Intent();
Intent launchIntent = new Intent(this,RemoteCanvasActivity.class);

Intent launchIntent = new Intent(this, RemoteCanvasActivity.class);
Uri.Builder builder = new Uri.Builder();
builder.authority(Utils.getConnectionString(this) + ":" + connection.get_Id());
builder.scheme(Utils.getConnectionScheme(this));
launchIntent.setData(builder.build());

Log.d(TAG, "EXTRA_SHORTCUT_INTENT: " + launchIntent.getData());
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchIntent);
Log.d(TAG, "EXTRA_SHORTCUT_NAME: " + connection.getNickname());
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, connection.getNickname());
Log.d(TAG, "EXTRA_SHORTCUT_ICON_RESOURCE: " + icon);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);

setResult(RESULT_OK, intent);
}
else
Log.d(TAG, "RESULT_OK");
} else {
setResult(RESULT_CANCELED);

Log.d(TAG, "RESULT_CANCELED");
}

finish();
}

Expand All @@ -141,7 +148,7 @@ protected void onDestroy() {
}
super.onDestroy();
}

private boolean isMasterPasswordEnabled() {
SharedPreferences sp = getSharedPreferences(Constants.generalSettingsTag, Context.MODE_PRIVATE);
return sp.getBoolean(Constants.masterPasswordEnabledTag, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.Toast;

import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import android.widget.Toast;

import com.iiordanov.bVNC.RemoteCanvas;
import com.iiordanov.bVNC.Utils;
import com.iiordanov.bVNC.dialogs.GetTextFragment;
import com.undatech.opaque.Connection;
import com.undatech.opaque.MessageDialogs;
import com.undatech.opaque.RemoteClientLibConstants;
import java.security.cert.X509Certificate;

import com.undatech.remoteClientUi.R;

import java.security.cert.X509Certificate;

public class RemoteCanvasHandler extends Handler {
private static String TAG = "RemoteCanvasHandler";
private Context context;
Expand Down

0 comments on commit 035ee1c

Please sign in to comment.