String testing.

This commit is contained in:
B. Petersen
2016-09-19 21:59:10 +02:00
parent 36773ecd96
commit 4f06104f05
3 changed files with 79 additions and 3 deletions
+76
View File
@@ -0,0 +1,76 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Copyright (C) 2016 Björn Petersen Software Design and Development
* Contact: r10s@b44t.com, http://b44t.com
*
* This program 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 3 of the License, or (at your option) any later
* version.
*
* This program 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.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see http://www.gnu.org/licenses/ .
*
*******************************************************************************
*
* File: mr_wrapper.c
* Authors: Björn Petersen
* Purpose: The C part of the Java<->C Wrapper, see also MrMailbox.java
*
******************************************************************************/
#include <jni.h>
#include "../../../messenger-backend/src/mrmailbox.h"
/*******************************************************************************
* MrMailbox
******************************************************************************/
JNIEXPORT jlong Java_org_telegram_messenger_MrMailbox_MrMailboxNew(JNIEnv *env, jclass c)
{
return (jlong)mrmailbox_new();
}
JNIEXPORT jlong Java_org_telegram_messenger_MrMailbox_MrMailboxDelete(JNIEnv *env, jclass c, jlong hMailbox)
{
mrmailbox_delete((mrmailbox_t*)hMailbox);
}
JNIEXPORT int Java_org_telegram_messenger_MrMailbox_MrMailboxOpen(JNIEnv *env, jclass c, jlong hMailbox, jstring dbfile)
{
const char* dbfilePtr = (*env)->GetStringUTFChars(env, dbfile, 0);
if( dbfilePtr == NULL ) { return 0; }
int ret = mrmailbox_open((mrmailbox_t*)hMailbox, dbfilePtr);
(*env)->ReleaseStringUTFChars(env, dbfile, dbfilePtr);
return ret;
}
JNIEXPORT void Java_org_telegram_messenger_MrMailbox_MrMailboxClose(JNIEnv *env, jclass c, jlong hMailbox)
{
mrmailbox_close((mrmailbox_t*)hMailbox);
}
/*******************************************************************************
* MrChat
******************************************************************************/
JNIEXPORT jstring Java_org_telegram_messenger_MrMailbox_MrChatGetName(JNIEnv *env, jclass c, jlong hChat)
{
return (*env)->NewStringUTF(env, "foobar test");
}
@@ -47,5 +47,5 @@ public class MrMailbox {
// working with chats
public native static int MrChatGetId (long hChat);
public native static int MrChatGetType (long hChat);
public native static String MrChatCetName (long hChat);
public native static String MrChatGetName (long hChat);
}
@@ -1328,7 +1328,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0);
int code = pInfo.versionCode / 10;
String abi = "";
long testval = MrMailbox.MrMailboxNew ();
String testval = MrMailbox.MrChatGetName (1);
switch (pInfo.versionCode % 10) {
case 0:
abi = "arm";
@@ -1343,7 +1343,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
abi = "universal";
break;
}
((TextInfoCell) view).setText(String.format(Locale.US, "%d ** Messenger for Android V%s (%d) %s",
((TextInfoCell) view).setText(String.format(Locale.US, "%s ** Messenger for Android V%s (%d) %s",
testval, pInfo.versionName, code, abi)); // EDIT BY ME
} catch (Exception e) {
FileLog.e("tmessages", e);