Android: Added SDCard redirection support
This commit is contained in:
parent
df2c096908
commit
c0dffd6edf
@ -3,11 +3,6 @@ set(OPTION_DEFAULT OFF)
|
||||
set(OPTION_CLIENT_DEFAULT ON)
|
||||
set(OPTION_SERVER_DEFAULT OFF)
|
||||
|
||||
if(ANDROID)
|
||||
set(OPTION_CLIENT_DEFAULT OFF)
|
||||
set(OPTION_SERVER_DEFAULT OFF)
|
||||
endif()
|
||||
|
||||
define_channel_options(NAME "drive" TYPE "device"
|
||||
DESCRIPTION "Drive Redirection Virtual Channel Extension"
|
||||
SPECIFICATIONS "[MS-RDPEFS]"
|
||||
|
@ -462,7 +462,11 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
|
||||
tv[1].tv_usec = 0;
|
||||
#ifndef WIN32
|
||||
/* TODO on win32 */
|
||||
futimes(file->fd, tv);
|
||||
#ifdef ANDROID
|
||||
utimes(file->fullpath, tv);
|
||||
#else
|
||||
futimes(file->fd, tv);
|
||||
#endif
|
||||
|
||||
if (FileAttributes > 0)
|
||||
{
|
||||
|
@ -63,6 +63,12 @@ typedef UINT32 mode_t;
|
||||
#define FSTAT fstat
|
||||
#define STATVFS statvfs
|
||||
#define O_LARGEFILE 0
|
||||
#elif defined(ANDROID)
|
||||
#define STAT stat
|
||||
#define OPEN open
|
||||
#define LSEEK lseek
|
||||
#define FSTAT fstat
|
||||
#define STATVFS statfs
|
||||
#else
|
||||
#define STAT stat64
|
||||
#define OPEN open64
|
||||
|
@ -407,7 +407,11 @@ static void drive_process_irp_query_volume_information(DRIVE_DEVICE* disk, IRP*
|
||||
stream_write_UINT32(output, 17 + length); /* Length */
|
||||
stream_check_size(output, 17 + length);
|
||||
stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* VolumeCreationTime */
|
||||
#ifdef ANDROID
|
||||
stream_write_UINT32(output, svfst.f_fsid.__val[0]); /* VolumeSerialNumber */
|
||||
#else
|
||||
stream_write_UINT32(output, svfst.f_fsid); /* VolumeSerialNumber */
|
||||
#endif
|
||||
stream_write_UINT32(output, length); /* VolumeLabelLength */
|
||||
stream_write_BYTE(output, 0); /* SupportsObjects */
|
||||
/* Reserved(1), MUST NOT be added! */
|
||||
@ -434,7 +438,11 @@ static void drive_process_irp_query_volume_information(DRIVE_DEVICE* disk, IRP*
|
||||
FILE_CASE_SENSITIVE_SEARCH |
|
||||
FILE_CASE_PRESERVED_NAMES |
|
||||
FILE_UNICODE_ON_DISK); /* FileSystemAttributes */
|
||||
#ifdef ANDROID
|
||||
stream_write_UINT32(output, 255); /* MaximumComponentNameLength */
|
||||
#else
|
||||
stream_write_UINT32(output, svfst.f_namemax/*510*/); /* MaximumComponentNameLength */
|
||||
#endif
|
||||
stream_write_UINT32(output, length); /* FileSystemNameLength */
|
||||
stream_write(output, outStr, length); /* FileSystemName (Unicode) */
|
||||
free(outStr);
|
||||
|
@ -9,6 +9,8 @@
|
||||
<uses-sdk android:targetSdkVersion="8" android:minSdkVersion="8"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<supports-screens android:anyDensity="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" />
|
||||
|
||||
<application>
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include <sys/select.h>
|
||||
#include <freerdp/codec/rfx.h>
|
||||
#include <freerdp/channels/channels.h>
|
||||
#include <freerdp/client/channels.h>
|
||||
#include <freerdp/client/cmdline.h>
|
||||
#include <freerdp/gdi/gdi.h>
|
||||
#include <freerdp/utils/event.h>
|
||||
#include <freerdp/constants.h>
|
||||
@ -119,7 +121,8 @@ BOOL android_pre_connect(freerdp* instance)
|
||||
|
||||
settings->FrameAcknowledge = 10;
|
||||
|
||||
freerdp_channels_load_plugin(instance->context->channels, instance->settings, "tsxlc", NULL);
|
||||
freerdp_register_addin_provider(freerdp_channels_load_static_addin_entry, 0);
|
||||
freerdp_client_load_addins(instance->context->channels, instance->settings);
|
||||
|
||||
freerdp_channels_pre_connect(instance->context->channels, instance);
|
||||
|
||||
@ -729,6 +732,22 @@ JNIEXPORT void JNICALL jni_freerdp_set_advanced_settings(JNIEnv *env, jclass cls
|
||||
(*env)->ReleaseStringUTFChars(env, jWorkDir, work_dir);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL jni_freerdp_set_drive_redirection(JNIEnv *env, jclass cls, jint instance, jstring jpath)
|
||||
{
|
||||
freerdp* inst = (freerdp*)instance;
|
||||
rdpSettings * settings = inst->settings;
|
||||
char* args[] = {"drive", "Android", ""};
|
||||
|
||||
const jbyte *path = (*env)->GetStringUTFChars(env, jpath, NULL);
|
||||
DEBUG_ANDROID("drive redirect: %s", (char*)path);
|
||||
|
||||
args[2] = (char*)path;
|
||||
freerdp_client_add_device_channel(settings, 3, args);
|
||||
settings->DeviceRedirection = TRUE;
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, jpath, path);
|
||||
}
|
||||
|
||||
void copy_pixel_buffer(UINT8* dstBuf, UINT8* srcBuf, int x, int y, int width, int height, int wBuf, int hBuf, int bpp)
|
||||
{
|
||||
int i, j;
|
||||
|
@ -42,6 +42,7 @@ JNIEXPORT void JNICALL jni_freerdp_set_connection_info(JNIEnv *env, jclass cls,
|
||||
JNIEXPORT void JNICALL jni_freerdp_set_performance_flags(JNIEnv *env, jclass cls, jint instance, jboolean remotefx, jboolean disableWallpaper, jboolean disableFullWindowDrag,
|
||||
jboolean disableMenuAnimations, jboolean disableTheming, jboolean enableFontSmoothing, jboolean enableDesktopComposition);
|
||||
JNIEXPORT void JNICALL jni_freerdp_set_advanced_settings(JNIEnv *env, jclass cls, jint instance, jstring jRemoteProgram, jstring jWorkDir);
|
||||
JNIEXPORT void JNICALL jni_freerdp_set_drive_redirection(JNIEnv *env, jclass cls, jint instance, jstring jpath);
|
||||
JNIEXPORT void JNICALL jni_freerdp_set_data_directory(JNIEnv *env, jclass cls, jint instance, jstring jdirectory);
|
||||
JNIEXPORT jboolean JNICALL jni_freerdp_update_graphics(JNIEnv *env, jclass cls, jint instance, jobject bitmap, jint x, jint y, jint width, jint height);
|
||||
JNIEXPORT void JNICALL jni_freerdp_send_cursor_event(JNIEnv *env, jclass cls, jint instance, jint x, jint y, jint flags);
|
||||
|
@ -70,6 +70,12 @@ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_
|
||||
jni_freerdp_set_performance_flags(env, cls, instance, remotefx, disableWallpaper, disableFullWindowDrag, disableMenuAnimations, disableTheming, enableFontSmoothing, enableDesktopComposition);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1drive_1redirection
|
||||
(JNIEnv *env, jclass cls, jint inst, jstring path)
|
||||
{
|
||||
jni_freerdp_set_drive_redirection(env, cls, inst, path);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1update_1graphics(
|
||||
JNIEnv *env, jclass cls, jint instance, jobject bitmap, jint x, jint y, jint width, jint height)
|
||||
{
|
||||
|
@ -79,6 +79,14 @@ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_
|
||||
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1data_1directory
|
||||
(JNIEnv *, jclass, jint, jstring);
|
||||
|
||||
/*
|
||||
* Class: com_freerdp_freerdpcore_services_LibFreeRDP
|
||||
* Method: freerdp_set_drive_redirection
|
||||
* Signature: (ILjava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1drive_1redirection
|
||||
(JNIEnv *, jclass, jint, jstring);
|
||||
|
||||
/*
|
||||
* Class: com_freerdp_freerdpcore_services_LibFreeRDP
|
||||
* Method: freerdp_update_graphics
|
||||
|
@ -28,7 +28,7 @@
|
||||
<string name="section_bookmarks">Conexión Manual</string>
|
||||
<string name="section_active_sessions">Sesiones Activas</string>
|
||||
<!-- Search strings -->
|
||||
<string name="search_hint">Connectarse a iWinCloud</string>
|
||||
<string name="search_hint">Connect to Computer</string>
|
||||
<!-- List placeholder labels -->
|
||||
<string name="list_placeholder_login">Login</string>
|
||||
<string name="list_placeholder_no_servers">No hay escritorios virtuales</string>
|
||||
@ -37,13 +37,13 @@
|
||||
<string name="list_placeholder_connection_error">Conexión perdida</string>
|
||||
<string name="list_placeholder_wrong_password">Contraseña equivocada</string>
|
||||
<string name="list_placeholder_invalid_username">Usuario Invalido</string>
|
||||
<string name="list_placeholder_add_bookmark">Agregar escritorio virtual de iWinCloud</string>
|
||||
<string name="list_placeholder_add_bookmark">Add Connection</string>
|
||||
<!-- Bookmark settings strings -->
|
||||
<string name="settings_cat_host">Host</string>
|
||||
<string name="settings_label">Su nombre</string>
|
||||
<string name="settings_hostname">IP</string>
|
||||
<string name="settings_port">Puerto</string>
|
||||
<string name="settings_cat_credentials">Credenciales de iWinCloud</string>
|
||||
<string name="settings_cat_credentials">Credenciales</string>
|
||||
<string name="settings_credentials">Credenciales</string>
|
||||
<string name="settings_username">Usuario</string>
|
||||
<string name="settings_password">Contraseña</string>
|
||||
@ -105,6 +105,7 @@
|
||||
<string name="settings_enable_3g_settings">Configuracion 3G</string>
|
||||
<string name="settings_screen_3g">Pantalla 3G</string>
|
||||
<string name="settings_performance_3g">Rendimiento 3G</string>
|
||||
<string name="settings_redirect_sdcard">Redirect SDCard</string>
|
||||
<string name="settings_security">Seguridad</string>
|
||||
<string-array name="security_array">
|
||||
<item>Automatico</item>
|
||||
@ -141,28 +142,28 @@
|
||||
<!-- Activity titles -->
|
||||
<string name="title_bookmark_settings">Configuración de la conexión</string>
|
||||
<string name="title_application_settings">Configuración</string>
|
||||
<string name="title_home">iWinCloud - iWinCloud para Android</string>
|
||||
<string name="title_home">aFreeRDP - aFreeRDP para Android</string>
|
||||
<string name="title_create_shortcut">Conexiones RDP</string>
|
||||
<string name="title_help">Ayuda</string>
|
||||
<string name="title_about">Sobre</string>
|
||||
<!-- Error message strings -->
|
||||
<string name="error_bookmark_incomplete_title">Cancelar sin guardar?</string>
|
||||
<string name="error_bookmark_incomplete">Pulse el botón "Cancelar" para abortar! \ NPulse "Continuar" para especificar los campos obligatorios!</string>
|
||||
<string name="error_connection_failure">No se pudo establecer una conexión con iWinCloud!</string>
|
||||
<string name="error_connection_failure">Failed to establish a connection to the server!</string>
|
||||
<!-- Info message strings -->
|
||||
<string name="info_capabilities_changed">Los ajustes de pantalla se han cambiado porque el escritorio virtual no es compatible con la configuración especificada!</string>
|
||||
<string name="info_reset_success">Eliminado el cache del certificado!</string>
|
||||
<string name="info_reset_failed">No se pudo borrar el caché del certificado!</string>
|
||||
<!-- Dialog strings -->
|
||||
<string name="dlg_title_verify_certificate">verificar el certificado</string>
|
||||
<string name="dlg_msg_verify_certificate">La identidad de su escritorio de iWinCloud debe ser verificada. ¿Desea conectarse de todos modos?</string>
|
||||
<string name="dlg_msg_verify_certificate">The identity of the remote computer cannot be verified. Do you want to connect anyway?</string>
|
||||
<string name="dlg_title_credentials">Por favor, introduzca sus credenciales</string>
|
||||
<string name="dlg_title_create_shortcut">Crear acceso directo</string>
|
||||
<string name="dlg_msg_create_shortcut">Nombre corto:</string>
|
||||
<string name="dlg_msg_connecting">Conectando ...</string>
|
||||
<string name="dlg_msg_logging_in">Ingresando a ...</string>
|
||||
<string name="dlg_title_about">Sobre iWinCloud</string>
|
||||
<string name="dlg_msg_about">Version: %1$s\n\u00A9 2012 iWinCloud LLc</string>
|
||||
<string name="dlg_title_about">Sobre aFreeRDP</string>
|
||||
<string name="dlg_msg_about">Version: %1$s\n\u00A9 2012 Thinstuff Technologies GmbH</string>
|
||||
<string name="dlg_title_create_bookmark_after_qc">Guardar configuración de conexión?</string>
|
||||
<string name="dlg_msg_create_bookmark_after_qc">La configuración de conexión no se han guardado! ¿Quieres guardarlos?</string>
|
||||
<string name="dlg_title_save_bookmark">Guardar Conexión</string>
|
||||
|
@ -104,6 +104,7 @@
|
||||
<string name="settings_enable_3g_settings">"Paramètres 3G"</string>
|
||||
<string name="settings_screen_3g">"Écran 3G"</string>
|
||||
<string name="settings_performance_3g">"Performance 3G"</string>
|
||||
<string name="settings_redirect_sdcard">"Redirect SDCard"</string>
|
||||
<string name="settings_security">"Securité"</string>
|
||||
<string-array name="security_array">
|
||||
<item>"Automatique"</item>
|
||||
|
@ -105,6 +105,7 @@
|
||||
<string name="settings_enable_3g_settings">3G Settings</string>
|
||||
<string name="settings_screen_3g">3G Screen</string>
|
||||
<string name="settings_performance_3g">3G Performance</string>
|
||||
<string name="settings_redirect_sdcard">Redirect SDCard</string>
|
||||
<string name="settings_security">Security</string>
|
||||
<string-array name="security_array">
|
||||
<item>Automatic</item>
|
||||
|
@ -28,6 +28,7 @@
|
||||
android:data="preferences://performance_flags_3g" />
|
||||
</PreferenceScreen>
|
||||
|
||||
<CheckBoxPreference android:key="bookmark.redirect_sdcard" android:title="@string/settings_redirect_sdcard"/>
|
||||
<com.freerdp.freerdpcore.utils.IntListPreference android:key="bookmark.security" android:title="@string/settings_security" android:entries="@array/security_array" android:entryValues="@array/security_values_array" />
|
||||
<EditTextPreference android:key="bookmark.remote_program" android:title="@string/settings_remote_program" android:summary="notepad.exe"/>
|
||||
<EditTextPreference android:key="bookmark.work_dir" android:title="@string/settings_work_dir"/>
|
||||
|
@ -284,6 +284,7 @@ public class BookmarkBase implements Parcelable, Cloneable
|
||||
private boolean enable3GSettings;
|
||||
private ScreenSettings screen3G;
|
||||
private PerformanceFlags performance3G;
|
||||
private boolean redirectSDCard;
|
||||
private int security;
|
||||
private boolean consoleMode;
|
||||
private String remoteProgram;
|
||||
@ -297,6 +298,7 @@ public class BookmarkBase implements Parcelable, Cloneable
|
||||
enable3GSettings = (parcel.readInt() == 1) ? true : false;
|
||||
screen3G = parcel.readParcelable(ScreenSettings.class.getClassLoader());
|
||||
performance3G = parcel.readParcelable(PerformanceFlags.class.getClassLoader());
|
||||
redirectSDCard = (parcel.readInt() == 1) ? true : false;
|
||||
security = parcel.readInt();
|
||||
consoleMode = (parcel.readInt() == 1) ? true : false;
|
||||
remoteProgram = parcel.readString();
|
||||
@ -307,6 +309,7 @@ public class BookmarkBase implements Parcelable, Cloneable
|
||||
enable3GSettings = false;
|
||||
screen3G = new ScreenSettings();
|
||||
performance3G = new PerformanceFlags();
|
||||
redirectSDCard = false;
|
||||
security = 0;
|
||||
consoleMode = false;
|
||||
remoteProgram = "";
|
||||
@ -337,6 +340,14 @@ public class BookmarkBase implements Parcelable, Cloneable
|
||||
this.performance3G = performance3G;
|
||||
}
|
||||
|
||||
public void setRedirectSDCard(boolean redirectSDCard) {
|
||||
this.redirectSDCard = redirectSDCard;
|
||||
}
|
||||
|
||||
public boolean getRedirectSDCard() {
|
||||
return redirectSDCard;
|
||||
}
|
||||
|
||||
public void setSecurity(int security) {
|
||||
this.security = security;
|
||||
}
|
||||
@ -396,6 +407,7 @@ public class BookmarkBase implements Parcelable, Cloneable
|
||||
out.writeInt(enable3GSettings ? 1 : 0);
|
||||
out.writeParcelable(screen3G, flags);
|
||||
out.writeParcelable(performance3G, flags);
|
||||
out.writeInt(redirectSDCard ? 1 : 0);
|
||||
out.writeInt(security);
|
||||
out.writeInt(consoleMode ? 1 : 0);
|
||||
out.writeString(remoteProgram);
|
||||
@ -597,6 +609,7 @@ public class BookmarkBase implements Parcelable, Cloneable
|
||||
editor.putBoolean("bookmark.perf_menu_animation_3g", advancedSettings.getPerformance3G().getMenuAnimations());
|
||||
editor.putBoolean("bookmark.perf_themes_3g", advancedSettings.getPerformance3G().getTheming());
|
||||
|
||||
editor.putBoolean("bookmark.redirect_sdcard", advancedSettings.getRedirectSDCard());
|
||||
editor.putInt("bookmark.security", advancedSettings.getSecurity());
|
||||
editor.putString("bookmark.remote_program", advancedSettings.getRemoteProgram());
|
||||
editor.putString("bookmark.work_dir", advancedSettings.getWorkDir());
|
||||
@ -638,6 +651,7 @@ public class BookmarkBase implements Parcelable, Cloneable
|
||||
advancedSettings.getPerformance3G().setMenuAnimations(sharedPrefs.getBoolean("bookmark.perf_menu_animation_3g", false));
|
||||
advancedSettings.getPerformance3G().setTheming(sharedPrefs.getBoolean("bookmark.perf_themes_3g", false));
|
||||
|
||||
advancedSettings.setRedirectSDCard(sharedPrefs.getBoolean("bookmark.redirect_sdcard", false));
|
||||
advancedSettings.setSecurity(sharedPrefs.getInt("bookmark.security", 0));
|
||||
advancedSettings.setRemoteProgram(sharedPrefs.getString("bookmark.remote_program", ""));
|
||||
advancedSettings.setWorkDir(sharedPrefs.getString("bookmark.work_dir", ""));
|
||||
|
@ -63,6 +63,7 @@ public abstract class BookmarkBaseGateway
|
||||
values.put("screen_3g", rowid);
|
||||
rowid = insertPerformanceFlags(db, bookmark.getAdvancedSettings().getPerformance3G());
|
||||
values.put("performance_3g", rowid);
|
||||
values.put("redirect_sdcard", bookmark.getAdvancedSettings().getRedirectSDCard());
|
||||
values.put("security", bookmark.getAdvancedSettings().getSecurity());
|
||||
values.put("console_mode", bookmark.getAdvancedSettings().getConsoleMode());
|
||||
values.put("remote_program", bookmark.getAdvancedSettings().getRemoteProgram());
|
||||
@ -98,6 +99,7 @@ public abstract class BookmarkBaseGateway
|
||||
// update 3G screen and 3G performance settings settings
|
||||
updateScreenSettings3G(db, bookmark);
|
||||
updatePerformanceFlags3G(db, bookmark);
|
||||
values.put("redirect_sdcard", bookmark.getAdvancedSettings().getRedirectSDCard());
|
||||
values.put("security", bookmark.getAdvancedSettings().getSecurity());
|
||||
values.put("console_mode", bookmark.getAdvancedSettings().getConsoleMode());
|
||||
values.put("remote_program", bookmark.getAdvancedSettings().getRemoteProgram());
|
||||
@ -216,6 +218,7 @@ public abstract class BookmarkBaseGateway
|
||||
|
||||
// advanced settings
|
||||
columns.add("enable_3g_settings");
|
||||
columns.add("redirect_sdcard");
|
||||
columns.add("security");
|
||||
columns.add("console_mode");
|
||||
columns.add("remote_program");
|
||||
@ -273,6 +276,7 @@ public abstract class BookmarkBaseGateway
|
||||
bookmark.getAdvancedSettings().setEnable3GSettings(cursor.getInt(cursor.getColumnIndex("enable_3g_settings")) == 0 ? false : true);
|
||||
readScreenSettings3G(bookmark, cursor);
|
||||
readPerformanceFlags3G(bookmark, cursor);
|
||||
bookmark.getAdvancedSettings().setRedirectSDCard(cursor.getInt(cursor.getColumnIndex("redirect_sdcard")) == 0 ? false : true);
|
||||
bookmark.getAdvancedSettings().setSecurity(cursor.getInt(cursor.getColumnIndex("security")));
|
||||
bookmark.getAdvancedSettings().setConsoleMode(cursor.getInt(cursor.getColumnIndex("console_mode")) == 0 ? false : true);
|
||||
bookmark.getAdvancedSettings().setRemoteProgram(cursor.getString(cursor.getColumnIndex("remote_program")));
|
||||
|
@ -9,14 +9,20 @@
|
||||
|
||||
package com.freerdp.freerdpcore.services;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.BaseColumns;
|
||||
import android.util.Log;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
public class BookmarkDB extends SQLiteOpenHelper
|
||||
{
|
||||
private static final int DB_VERSION = 1;
|
||||
private static final int DB_VERSION = 2;
|
||||
private static final String DB_NAME = "bookmarks.db";
|
||||
|
||||
public static final String ID = BaseColumns._ID;
|
||||
@ -52,33 +58,7 @@ public class BookmarkDB extends SQLiteOpenHelper
|
||||
|
||||
db.execSQL(sqlPerformanceFlags);
|
||||
|
||||
String sqlManualBookmarks =
|
||||
"CREATE TABLE tbl_manual_bookmarks ("
|
||||
+ ID + " INTEGER PRIMARY KEY, "
|
||||
+ "label TEXT NOT NULL, "
|
||||
+ "hostname TEXT NOT NULL, "
|
||||
+ "username TEXT NOT NULL, "
|
||||
+ "password TEXT, "
|
||||
+ "domain TEXT, "
|
||||
+ "port TEXT, "
|
||||
+ "screen_settings INTEGER NOT NULL, "
|
||||
+ "performance_flags INTEGER NOT NULL, "
|
||||
|
||||
+ "enable_3g_settings INTEGER DEFAULT 0, "
|
||||
+ "screen_3g INTEGER NOT NULL, "
|
||||
+ "performance_3g INTEGER NOT NULL, "
|
||||
+ "security INTEGER, "
|
||||
+ "remote_program TEXT, "
|
||||
+ "work_dir TEXT, "
|
||||
+ "console_mode INTEGER, "
|
||||
|
||||
+ "FOREIGN KEY(screen_settings) REFERENCES tbl_screen_settings(" + ID + "), "
|
||||
+ "FOREIGN KEY(performance_flags) REFERENCES tbl_performance_flags(" + ID + "), "
|
||||
+ "FOREIGN KEY(screen_3g) REFERENCES tbl_screen_settings(" + ID + "), "
|
||||
+ "FOREIGN KEY(performance_3g) REFERENCES tbl_performance_flags(" + ID + ") "
|
||||
|
||||
+ ");";
|
||||
|
||||
String sqlManualBookmarks = getManualBookmarksCreationString();
|
||||
db.execSQL(sqlManualBookmarks);
|
||||
|
||||
|
||||
@ -120,6 +100,7 @@ public class BookmarkDB extends SQLiteOpenHelper
|
||||
+ "performance_flags, "
|
||||
+ "screen_3g, "
|
||||
+ "performance_3g, "
|
||||
+ "redirect_sdcard, "
|
||||
+ "security, "
|
||||
+ "remote_program, "
|
||||
+ "work_dir, "
|
||||
@ -131,12 +112,94 @@ public class BookmarkDB extends SQLiteOpenHelper
|
||||
+ "'', "
|
||||
+ "'', "
|
||||
+ "3389, "
|
||||
+ "1, 1, 2, 2, 0, '', '', 0);";
|
||||
+ "1, 1, 2, 2, 0, 0, '', '', 0);";
|
||||
db.execSQL(sqlInsertDefaultSessionEntry);
|
||||
}
|
||||
|
||||
private String getManualBookmarksCreationString()
|
||||
{
|
||||
return (
|
||||
"CREATE TABLE IF NOT EXISTS tbl_manual_bookmarks ("
|
||||
+ ID + " INTEGER PRIMARY KEY, "
|
||||
+ "label TEXT NOT NULL, "
|
||||
+ "hostname TEXT NOT NULL, "
|
||||
+ "username TEXT NOT NULL, "
|
||||
+ "password TEXT, "
|
||||
+ "domain TEXT, "
|
||||
+ "port TEXT, "
|
||||
+ "screen_settings INTEGER NOT NULL, "
|
||||
+ "performance_flags INTEGER NOT NULL, "
|
||||
|
||||
+ "enable_3g_settings INTEGER DEFAULT 0, "
|
||||
+ "screen_3g INTEGER NOT NULL, "
|
||||
+ "performance_3g INTEGER NOT NULL, "
|
||||
+ "redirect_sdcard INTEGER, "
|
||||
+ "security INTEGER, "
|
||||
+ "remote_program TEXT, "
|
||||
+ "work_dir TEXT, "
|
||||
+ "console_mode INTEGER, "
|
||||
|
||||
+ "FOREIGN KEY(screen_settings) REFERENCES tbl_screen_settings(" + ID + "), "
|
||||
+ "FOREIGN KEY(performance_flags) REFERENCES tbl_performance_flags(" + ID + "), "
|
||||
+ "FOREIGN KEY(screen_3g) REFERENCES tbl_screen_settings(" + ID + "), "
|
||||
+ "FOREIGN KEY(performance_3g) REFERENCES tbl_performance_flags(" + ID + ") "
|
||||
|
||||
+ ");");
|
||||
}
|
||||
|
||||
// from http://stackoverflow.com/questions/3424156/upgrade-sqlite-database-from-one-version-to-another
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
|
||||
{
|
||||
{
|
||||
db.beginTransaction();
|
||||
|
||||
// run a table creation with if not exists (we are doing an upgrade, so the table might
|
||||
// not exists yet, it will fail alter and drop)
|
||||
db.execSQL(getManualBookmarksCreationString());
|
||||
// put in a list the existing columns
|
||||
List<String> columns = GetColumns(db, "tbl_manual_bookmarks");
|
||||
// backup table
|
||||
db.execSQL("ALTER TABLE tbl_manual_bookmarks RENAME TO 'temp_tbl_manual_bookmarks'");
|
||||
// create new table (with new scheme)
|
||||
db.execSQL(getManualBookmarksCreationString());
|
||||
// get the intersection with the new columns, this time columns taken from the upgraded table
|
||||
columns.retainAll(GetColumns(db, "tbl_manual_bookmarks"));
|
||||
// restore data
|
||||
String cols = joinStrings(columns, ",");
|
||||
db.execSQL(String.format("INSERT INTO %s (%s) SELECT %s from 'temp_%s", "tbl_manual_bookmarks", cols, cols, "tbl_manual_bookmarks'"));
|
||||
// remove backup table
|
||||
db.execSQL("DROP table 'temp_tbl_manual_bookmarks'");
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
db.endTransaction();
|
||||
}
|
||||
|
||||
private static List<String> GetColumns(SQLiteDatabase db, String tableName) {
|
||||
List<String> ar = null;
|
||||
Cursor c = null;
|
||||
try {
|
||||
c = db.rawQuery("SELECT * FROM " + tableName + " LIMIT 1", null);
|
||||
if (c != null) {
|
||||
ar = new ArrayList<String>(Arrays.asList(c.getColumnNames()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.v(tableName, e.getMessage(), e);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (c != null)
|
||||
c.close();
|
||||
}
|
||||
return ar;
|
||||
}
|
||||
|
||||
private static String joinStrings(List<String> list, String delim) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
int num = list.size();
|
||||
for (int i = 0; i < num; i++) {
|
||||
if (i != 0)
|
||||
buf.append(delim);
|
||||
buf.append((String) list.get(i));
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,8 @@ public class LibFreeRDP
|
||||
|
||||
private static native void freerdp_set_data_directory(int inst, String directory);
|
||||
|
||||
private static native void freerdp_set_drive_redirection(int inst, String path);
|
||||
|
||||
private static native boolean freerdp_update_graphics(int inst,
|
||||
Bitmap bitmap, int x, int y, int width, int height);
|
||||
|
||||
@ -143,6 +145,10 @@ public class LibFreeRDP
|
||||
BookmarkBase.AdvancedSettings advancedSettings = bookmark.getAdvancedSettings();
|
||||
freerdp_set_advanced_settings(inst, advancedSettings.getRemoteProgram(), advancedSettings.getWorkDir());
|
||||
|
||||
// drive redirection enabled?
|
||||
if (advancedSettings.getRedirectSDCard())
|
||||
freerdp_set_drive_redirection(inst, android.os.Environment.getExternalStorageDirectory().getPath());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user