mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Speed up array creation on 32 bit systems (AFAIK, all), add function to get all known contact IDs.
This commit is contained in:
@@ -1606,7 +1606,6 @@ LOCAL_SRC_FILES += \
|
||||
../../../messenger-backend/src/mrchat.c \
|
||||
../../../messenger-backend/src/mrchatlist.c \
|
||||
../../../messenger-backend/src/mrcontact.c \
|
||||
../../../messenger-backend/src/mrcontactlist.c \
|
||||
../../../messenger-backend/src/mrimap.c \
|
||||
../../../messenger-backend/src/mrjob.c \
|
||||
../../../messenger-backend/src/mrlog.c \
|
||||
|
||||
@@ -83,6 +83,35 @@ static void s_init_globals(JNIEnv *env, jclass MrMailbox_class)
|
||||
}
|
||||
|
||||
|
||||
/* tools */
|
||||
|
||||
static jintArray carray2jintArray_n_carray_free(JNIEnv *env, const carray* ca)
|
||||
{
|
||||
int i, icnt = ca? carray_count(ca) : 0;
|
||||
jintArray ret = (*env)->NewIntArray(env, icnt); if (ret == NULL) { return NULL; }
|
||||
|
||||
if( ca ) {
|
||||
if( icnt ) {
|
||||
void** ca_data = carray_data(ca);
|
||||
if( sizeof(void*)==sizeof(jint) ) {
|
||||
(*env)->SetIntArrayRegion(env, ret, 0, icnt, (jint*)ca_data);
|
||||
}
|
||||
else {
|
||||
jint* temp = calloc(icnt, sizeof(jint));
|
||||
for( i = 0; i < icnt; i++ ) {
|
||||
temp[i] = (jint)ca_data[i];
|
||||
}
|
||||
(*env)->SetIntArrayRegion(env, ret, 0, icnt, temp);
|
||||
free(temp);
|
||||
}
|
||||
}
|
||||
carray_free(ca);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* MrMailbox
|
||||
******************************************************************************/
|
||||
@@ -169,6 +198,12 @@ JNIEXPORT jint Java_org_telegram_messenger_MrMailbox_MrMailboxFetch(JNIEnv *env,
|
||||
|
||||
/* MrMailbox - handle contacts */
|
||||
|
||||
JNIEXPORT jintArray Java_org_telegram_messenger_MrMailbox_MrMailboxGetKnownContacts(JNIEnv *env, jclass c, jlong hMailbox)
|
||||
{
|
||||
carray* ca = mrmailbox_get_known_contacts((mrmailbox_t*)hMailbox);
|
||||
return carray2jintArray_n_carray_free(env, ca);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong Java_org_telegram_messenger_MrMailbox_MrMailboxGetContact(JNIEnv *env, jclass c, jlong hMailbox, jint id)
|
||||
{
|
||||
return (jlong)mrmailbox_get_contact((mrmailbox_t*)hMailbox, id);
|
||||
@@ -444,28 +479,6 @@ JNIEXPORT jint Java_org_telegram_messenger_MrMailbox_MrChatSendMedia(JNIEnv *env
|
||||
}
|
||||
|
||||
|
||||
static jintArray carray2jintArray_n_carray_free(JNIEnv *env, const carray* ca)
|
||||
{
|
||||
int i, icnt = ca? carray_count(ca) : 0;
|
||||
jintArray ret = (*env)->NewIntArray(env, icnt); if (ret == NULL) { return NULL; }
|
||||
|
||||
if( ca ) {
|
||||
if( icnt ) {
|
||||
void** ca_data = carray_data(ca);
|
||||
jint* temp = calloc(icnt, sizeof(jint));
|
||||
for( i = 0; i < icnt; i++ ) {
|
||||
temp[i] = (jint)ca_data[i];
|
||||
}
|
||||
(*env)->SetIntArrayRegion(env, ret, 0, icnt, temp);
|
||||
free(temp);
|
||||
}
|
||||
carray_free(ca);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jintArray Java_org_telegram_messenger_MrMailbox_MrMailboxGetChatMedia(JNIEnv *env, jclass c, jlong hMailbox, jint chat_id, jint msg_type, jint or_msg_type)
|
||||
{
|
||||
carray* ca = mrmailbox_get_chat_media((mrmailbox_t*)hMailbox, chat_id, msg_type, or_msg_type);
|
||||
|
||||
@@ -218,6 +218,7 @@ public class MrMailbox {
|
||||
public native static void MrMailboxDisconnect (long hMailbox);
|
||||
public native static int MrMailboxFetch (long hMailbox);
|
||||
|
||||
public native static int[] MrMailboxGetKnownContacts (long hMailbox);
|
||||
public native static long MrMailboxGetContact (long hMailbox, int id);// returns hContact which must be unref'd after usage
|
||||
|
||||
public native static long MrMailboxGetChatlist (long hMailbox); // returns hChatlist which must be unref'd after usage
|
||||
|
||||
@@ -36,11 +36,6 @@ public class TLRPC {
|
||||
public static class TL_chatPhotoEmpty extends ChatPhoto {
|
||||
}
|
||||
|
||||
public static class TL_error extends TLObject {
|
||||
public int code;
|
||||
public String text;
|
||||
}
|
||||
|
||||
public static class DocumentAttribute extends TLObject {
|
||||
public int w;
|
||||
public int h;
|
||||
@@ -293,10 +288,8 @@ public class TLRPC {
|
||||
public boolean deleted;
|
||||
public final boolean bot = false;
|
||||
public boolean verified;
|
||||
public boolean restricted_;
|
||||
public boolean min;
|
||||
public String restriction_reason;
|
||||
public String bot_inline_placeholder;
|
||||
}
|
||||
|
||||
public static class TL_userContact_old2 extends User {
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
private boolean needPhonebook;
|
||||
private boolean destroyAfterSelect;
|
||||
private boolean returnAsResult;
|
||||
private boolean createSecretChat;
|
||||
private final boolean createSecretChat = false;
|
||||
private boolean creatingChat = false;
|
||||
private boolean allowBots = true;
|
||||
private boolean needForwardCount = true;
|
||||
@@ -98,7 +98,6 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
onlyUsers = getArguments().getBoolean("onlyUsers", false);
|
||||
destroyAfterSelect = arguments.getBoolean("destroyAfterSelect", false);
|
||||
returnAsResult = arguments.getBoolean("returnAsResult", false);
|
||||
createSecretChat = arguments.getBoolean("createSecretChat", false);
|
||||
selectAlertString = arguments.getString("selectAlertString");
|
||||
allowUsernameSearch = arguments.getBoolean("allowUsernameSearch", true);
|
||||
needForwardCount = arguments.getBoolean("needForwardCount", true);
|
||||
@@ -132,9 +131,9 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
if (returnAsResult) {
|
||||
actionBar.setTitle(LocaleController.getString("SelectContact", R.string.SelectContact));
|
||||
} else {
|
||||
if (createSecretChat) {
|
||||
/*if (createSecretChat) {
|
||||
actionBar.setTitle(LocaleController.getString("NewSecretChat", R.string.NewSecretChat));
|
||||
} else {
|
||||
} else*/ {
|
||||
actionBar.setTitle(LocaleController.getString("NewMessageTitle", R.string.NewMessageTitle));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user