Skip to content

Commit

Permalink
MainService,native: wire up http root dir
Browse files Browse the repository at this point in the history
re #6
  • Loading branch information
bk138 committed Aug 15, 2024
1 parent e9ea9fa commit 5680a1e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
13 changes: 12 additions & 1 deletion app/src/main/cpp/droidvnc-ng.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ JNIEXPORT jboolean JNICALL Java_net_christianbeier_droidvnc_1ng_MainService_vncS
free(theScreen->frameBuffer);
theScreen->frameBuffer = NULL;
free((char*)theScreen->desktopName); // always malloc'ed by us
free(theScreen->httpDir); // always malloc'ed by us
theScreen->desktopName = NULL;
if(theScreen->authPasswdData) { // if this is set, it was malloc'ed by us and has one password in there
char **passwordList = theScreen->authPasswdData;
Expand All @@ -287,7 +288,7 @@ JNIEXPORT jboolean JNICALL Java_net_christianbeier_droidvnc_1ng_MainService_vncS
}


JNIEXPORT jboolean JNICALL Java_net_christianbeier_droidvnc_1ng_MainService_vncStartServer(JNIEnv *env, jobject thiz, jint width, jint height, jint port, jstring desktopname, jstring password) {
JNIEXPORT jboolean JNICALL Java_net_christianbeier_droidvnc_1ng_MainService_vncStartServer(JNIEnv *env, jobject thiz, jint width, jint height, jint port, jstring desktopname, jstring password, jstring httpRootDir) {

int argc = 0;

Expand Down Expand Up @@ -355,6 +356,16 @@ JNIEXPORT jboolean JNICALL Java_net_christianbeier_droidvnc_1ng_MainService_vncS
(*env)->ReleaseStringUTFChars(env, password, cPassword);
}

if(httpRootDir) { // string arg to GetStringUTFChars() must not be NULL
const char *cHttpRootDir = (*env)->GetStringUTFChars(env, httpRootDir, NULL);
if(!cHttpRootDir) {
__android_log_print(ANDROID_LOG_ERROR, TAG, "vncStartServer: failed getting http root dir from JNI");
Java_net_christianbeier_droidvnc_1ng_MainService_vncStopServer(env, thiz);
return JNI_FALSE;
}
theScreen->httpDir = strdup(cHttpRootDir);
(*env)->ReleaseStringUTFChars(env, httpRootDir, cHttpRootDir);
}

rfbInitServer(theScreen);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public void onServiceUnregistered(NsdServiceInfo nsdServiceInfo) {
}

@SuppressWarnings("BooleanMethodIsAlwaysInverted")
private native boolean vncStartServer(int width, int height, int port, String desktopName, String password);
private native boolean vncStartServer(int width, int height, int port, String desktopName, String password, String httpRootDir);
private native boolean vncStopServer();
private native boolean vncIsActive();
private native long vncConnectReverse(String host, int port);
Expand Down Expand Up @@ -339,7 +339,8 @@ public int onStartCommand(Intent intent, int flags, int startId)
displayMetrics.heightPixels,
port,
name,
PreferenceManager.getDefaultSharedPreferences(this).getString(PREFS_KEY_SERVER_LAST_PASSWORD, mDefaults.getPassword()));
PreferenceManager.getDefaultSharedPreferences(this).getString(PREFS_KEY_SERVER_LAST_PASSWORD, mDefaults.getPassword()),
getFilesDir().getAbsolutePath() + File.separator + "novnc");
Intent answer = new Intent(ACTION_START);
answer.putExtra(EXTRA_REQUEST_ID, PreferenceManager.getDefaultSharedPreferences(this).getString(PREFS_KEY_SERVER_LAST_START_REQUEST_ID, null));
answer.putExtra(EXTRA_REQUEST_SUCCESS, status);
Expand Down Expand Up @@ -379,7 +380,8 @@ public int onStartCommand(Intent intent, int flags, int startId)
displayMetrics.heightPixels,
port,
name,
PreferenceManager.getDefaultSharedPreferences(this).getString(PREFS_KEY_SERVER_LAST_PASSWORD, mDefaults.getPassword()));
PreferenceManager.getDefaultSharedPreferences(this).getString(PREFS_KEY_SERVER_LAST_PASSWORD, mDefaults.getPassword()),
getFilesDir().getAbsolutePath() + File.separator + "novnc");

Intent answer = new Intent(ACTION_START);
answer.putExtra(EXTRA_REQUEST_ID, PreferenceManager.getDefaultSharedPreferences(this).getString(PREFS_KEY_SERVER_LAST_START_REQUEST_ID, null));
Expand Down

0 comments on commit 5680a1e

Please sign in to comment.