Skip to content

Commit

Permalink
- added sound enable/disable option
Browse files Browse the repository at this point in the history
  • Loading branch information
iiordanov committed Oct 11, 2013
1 parent e9b670f commit 25372a8
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 16 deletions.
3 changes: 2 additions & 1 deletion eclipse_projects/bVNC/jni/src/android/android-service.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ Java_com_iiordanov_aSPICE_SpiceCommunicator_SpiceClientDisconnect (JNIEnv * env,

JNIEXPORT jint JNICALL
Java_com_iiordanov_aSPICE_SpiceCommunicator_SpiceClientConnect (JNIEnv *env, jobject obj, jstring h, jstring p,
jstring tp, jstring pw, jstring cf, jstring cs)
jstring tp, jstring pw, jstring cf, jstring cs, jboolean sound)
{
int result = 0;
maintainConnection = TRUE;
soundEnabled = sound;

// Get a reference to the JVM to get JNIEnv from in (other) threads.
jint rs = (*env)->GetJavaVM(env, &jvm);
Expand Down
2 changes: 2 additions & 0 deletions eclipse_projects/bVNC/jni/src/android/android-service.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
jmethodID jni_graphics_update = NULL;
GMainLoop *mainloop = NULL;
int connections = 0;
gboolean soundEnabled = FALSE;
#else
extern SpiceDisplay* global_display;
extern gboolean maintainConnection;
Expand All @@ -42,4 +43,5 @@
extern jmethodID jni_graphics_update;
extern GMainLoop *mainloop;
extern int connections;
extern gboolean soundEnabled;
#endif
2 changes: 1 addition & 1 deletion eclipse_projects/bVNC/jni/src/android/android-spicy.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data)
// G_CALLBACK(inputs_modifiers), conn);
}

if (SPICE_IS_PLAYBACK_CHANNEL(channel)) {
if (soundEnabled && SPICE_IS_PLAYBACK_CHANNEL(channel)) {
SPICE_DEBUG("new audio channel");
conn->audio = spice_audio_get(s, NULL);
}
Expand Down
9 changes: 8 additions & 1 deletion eclipse_projects/bVNC/res/layout-large/main_spice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,14 @@ android:layout_height="fill_parent">
android:layout_height="wrap_content"
android:text="Local Device Tweaks"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<CheckBox
<CheckBox
android:id="@+id/checkboxEnableSound"
android:text="@string/enable_sound"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:gravity="left|center_vertical"
android:layout_height="wrap_content"/>
<CheckBox
android:id="@+id/checkboxUseDpadAsArrows"
android:text="@string/dpad_as_arrows"
android:textAppearance="?android:attr/textAppearanceLarge"
Expand Down
7 changes: 7 additions & 0 deletions eclipse_projects/bVNC/res/layout/main_spice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ android:layout_height="fill_parent">
android:layout_height="wrap_content"
android:text="Local Device Tweaks"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<CheckBox
android:id="@+id/checkboxEnableSound"
android:text="@string/enable_sound"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:gravity="left|center_vertical"
android:layout_height="wrap_content"/>
<CheckBox
android:id="@+id/checkboxUseDpadAsArrows"
android:text="@string/dpad_as_arrows"
Expand Down
1 change: 1 addition & 0 deletions eclipse_projects/bVNC/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
<string name="delete_key_list">Delete Key List</string>
<string name="dpad_as_arrows">Use D-Pad for arrows and D-Pad click for Ctrl.</string>
<string name="disconnect">Disconnect</string>
<string name="enable_sound">Enable Sound</string>
<string name="export_settings">Export</string>
<string name="export_settings_path"></string>
<string name="enter_text_title">Enter Text to Send</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public class ConnectionBean extends AbstractConnectionBean implements Comparable
setWindowContents(false);
setMenuAnimation(false);
setVisualStyles(false);
setEnableSound(false);
c = context;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,6 @@ interface IConnectionBean {
boolean getMenuAnimation();
@FieldAccessor
boolean getVisualStyles();
@FieldAccessor
boolean getEnableSound();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class SpiceCommunicator implements RfbConnectable, RdpKeyboardMapper.KeyProcessingListener {
private final static String TAG = "SpiceCommunicator";

public native int SpiceClientConnect (String ip, String port, String tport, String password, String ca_file, String cert_subj);
public native int SpiceClientConnect (String ip, String port, String tport, String password, String ca_file, String cert_subj, boolean sound);
public native void SpiceClientDisconnect ();
public native void SpiceButtonEvent (int x, int y, int metaState, int pointerMask);
public native void SpiceKeyEvent (boolean keyDown, int virtualKeyCode);
Expand Down Expand Up @@ -61,9 +61,9 @@ public Handler getHandler() {
return handler;
}

public void connect(String ip, String port, String tport, String password, String cf, String cs) {
public void connect(String ip, String port, String tport, String password, String cf, String cs, boolean sound) {
android.util.Log.e(TAG, ip + ", " + port + ", " + tport + ", " + password + ", " + cf + ", " + cs);
spicehread = new SpiceThread(ip, port, tport, password, cf, cs);
spicehread = new SpiceThread(ip, port, tport, password, cf, cs, sound);
spicehread.start();
}

Expand All @@ -74,18 +74,20 @@ public void disconnect() {

class SpiceThread extends Thread {
private String ip, port, tport, password, cf, cs;
boolean sound;

public SpiceThread(String ip, String port, String tport, String password, String cf, String cs) {
public SpiceThread(String ip, String port, String tport, String password, String cf, String cs, boolean sound) {
this.ip = ip;
this.port = port;
this.tport = tport;
this.password = password;
this.cf = cf;
this.cs = cs;
this.sound = sound;
}

public void run() {
SpiceClientConnect (ip, port, tport, password, cf, cs);
SpiceClientConnect (ip, port, tport, password, cf, cs, sound);
android.util.Log.e(TAG, "SpiceClientConnect returned.");

// If we've exited SpiceClientConnect, the connection is certainly
Expand Down
3 changes: 2 additions & 1 deletion eclipse_projects/bVNC/src/com/iiordanov/bVNC/VncCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,8 @@ public void run() {
spicecomm.setUIEventListener(VncCanvas.this);
spicecomm.setHandler(handler);
spicecomm.connect(address, Integer.toString(port), Integer.toString(tport),
connection.getPassword(), connection.getCaCertPath(), connection.getCertSubject());
connection.getPassword(), connection.getCaCertPath(),
connection.getCertSubject(), connection.getEnableSound());

try {
synchronized(spicecomm) {
Expand Down
10 changes: 9 additions & 1 deletion eclipse_projects/bVNC/src/com/iiordanov/bVNC/VncDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ class VncDatabase extends SQLiteOpenHelper {
static final int DBV_1_9_0 = 308;
static final int DBV_2_0_0 = 309;
static final int DBV_2_1_0 = 329;
static final int DBV_2_1_1 = 335;

public final static String TAG = VncDatabase.class.toString();

VncDatabase(Context context) {
super(context, "VncDatabase", null, DBV_2_1_0);
super(context, "VncDatabase", null, DBV_2_1_1);
}

/* (non-Javadoc)
Expand Down Expand Up @@ -200,5 +201,12 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+AbstractConnectionBean.GEN_FIELD_CERTSUBJECT + " TEXT");
oldVersion = DBV_2_1_0;
}

if (oldVersion == DBV_2_1_0) {
Log.i(TAG,"Doing upgrade from 329 to 335");
db.execSQL("ALTER TABLE " + AbstractConnectionBean.GEN_TABLE_NAME + " ADD COLUMN "
+AbstractConnectionBean.GEN_FIELD_ENABLESOUND + " BOOLEAN DEFAULT FALSE");
oldVersion = DBV_2_1_1;
}
}
}
24 changes: 18 additions & 6 deletions eclipse_projects/bVNC/src/com/iiordanov/bVNC/aSPICE.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public class aSPICE extends Activity implements MainConfiguration {
private boolean isFree;
private boolean startingOrHasPaused = true;
private boolean isConnecting = false;
private CheckBox checkboxEnableSound;

static {
System.loadLibrary("gstreamer_android");
System.loadLibrary("spice-android");
Expand Down Expand Up @@ -193,9 +195,10 @@ public void onNothingSelected(AdapterView<?> ad) {
checkboxUseDpadAsArrows = (CheckBox) findViewById(R.id.checkboxUseDpadAsArrows);
checkboxRotateDpad = (CheckBox) findViewById(R.id.checkboxRotateDpad);
checkboxLocalCursor = (CheckBox) findViewById(R.id.checkboxUseLocalCursor);
checkboxEnableSound = (CheckBox) findViewById(R.id.checkboxEnableSound);

spinnerConnection = (Spinner) findViewById(R.id.spinnerConnection);
spinnerConnection
.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
spinnerConnection.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> ad, View view,
int itemIndex, long id) {
Expand All @@ -208,8 +211,8 @@ public void onNothingSelected(AdapterView<?> ad) {
selected = null;
}
});
spinnerConnection
.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

spinnerConnection.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

/*
* (non-Javadoc)
Expand All @@ -229,6 +232,7 @@ public boolean onItemLongClick(AdapterView<?> arg0,
}

});

goButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand All @@ -245,8 +249,7 @@ public void onClick(View view) {
// The advanced settings button.
toggleAdvancedSettings = (ToggleButton) findViewById(R.id.toggleAdvancedSettings);
layoutAdvancedSettings = (LinearLayout) findViewById(R.id.layoutAdvancedSettings);
toggleAdvancedSettings
.setOnCheckedChangeListener(new OnCheckedChangeListener() {
toggleAdvancedSettings.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton arg0,
boolean checked) {
Expand Down Expand Up @@ -467,6 +470,7 @@ public void updateViewFromSelected() {
checkboxUseDpadAsArrows.setChecked(selected.getUseDpadAsArrows());
checkboxRotateDpad.setChecked(selected.getRotateDpad());
checkboxLocalCursor.setChecked(selected.getUseLocalCursor());
checkboxEnableSound.setChecked(selected.getEnableSound());
textNickname.setText(selected.getNickname());
spinnerGeometry.setSelection(selected.getRdpResType());
resWidth.setText(Integer.toString(selected.getRdpWidth()));
Expand Down Expand Up @@ -588,6 +592,7 @@ private void updateSelectedFromView() {
selected.setUseDpadAsArrows(checkboxUseDpadAsArrows.isChecked());
selected.setRotateDpad(checkboxRotateDpad.isChecked());
selected.setUseLocalCursor(checkboxLocalCursor.isChecked());
selected.setEnableSound(checkboxEnableSound.isChecked());
}

protected void onStart() {
Expand Down Expand Up @@ -729,6 +734,13 @@ private void start () {
isConnecting = true;
updateSelectedFromView();
saveAndWriteRecent();
if (selected.getEnableSound()) {
try {
GStreamer.init(this);
} catch (Exception e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
}
}
Intent intent = new Intent(this, VncCanvasActivity.class);
intent.putExtra(VncConstants.CONNECTION, selected.Gen_getValues());
startActivity(intent);
Expand Down

0 comments on commit 25372a8

Please sign in to comment.