Fix calling forward function.

This commit is contained in:
B. Petersen
2017-01-27 12:40:01 +01:00
parent 03c30bef47
commit aa090a9cd4
4 changed files with 49 additions and 28 deletions
+20 -16
View File
@@ -82,7 +82,7 @@ static void s_log_callback_(int type, const char* msg)
}
/* globl stuff */
/* global stuff */
static JavaVM* s_jvm = NULL;
static jclass s_MrMailbox_class = NULL;
@@ -137,25 +137,29 @@ static jintArray carray2jintArray_n_carray_free(JNIEnv *env, const carray* ca)
}
static int* jintArray2uint32Pointer(JNIEnv* env, jintArray ja, int* icnt)
static uint32_t* jintArray2uint32Pointer(JNIEnv* env, jintArray ja, int* ret_icnt)
{
uint32_t* ret = NULL;
const jint* temp;
int i;
if( env && ja && icnt ) {
temp = (*env)->GetIntArrayElements(env, ja, NULL);
*icnt = (*env)->GetArrayLength(env, ja);
if( temp && *icnt > 0 ) {
ret = calloc(icnt, sizeof(uint32_t));
if( ret ) {
for( i = 0; i < icnt; i++ ) {
ret[i] = (uint32_t)temp[i];
uint32_t* ret = NULL;
if( env && ja && ret_icnt )
{
int i, icnt = (*env)->GetArrayLength(env, ja);
if( icnt > 0 )
{
const jint* temp = (*env)->GetIntArrayElements(env, ja, NULL);
if( temp )
{
ret = calloc(icnt, sizeof(uint32_t));
if( ret )
{
for( i = 0; i < icnt; i++ ) {
ret[i] = (uint32_t)temp[i];
}
*ret_icnt = icnt;
}
(*env)->ReleaseIntArrayElements(env, ja, temp, 0);
}
(*env)->ReleaseIntArrayElements(env, ja, temp, 0);
}
}
return ret;
}
@@ -433,7 +437,7 @@ JNIEXPORT void Java_com_b44t_messenger_MrMailbox_deleteMsg(JNIEnv *env, jclass c
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_forwardMsgs(JNIEnv *env, jclass cls, jintArray msg_ids, jint chat_id)
{
int msg_ids_cnt;
const int* msg_ids_ptr = jintArray2uint32Pointer(env, msg_ids, &msg_ids_cnt);
const uint32_t* msg_ids_ptr = jintArray2uint32Pointer(env, msg_ids, &msg_ids_cnt);
mrmailbox_forward_msgs(get_mrmailbox_t(env, cls), msg_ids_ptr, msg_ids_cnt, chat_id);
free(msg_ids_ptr);
}
@@ -174,7 +174,7 @@ public class MrMailbox {
}
public native static void deleteMsg(int id);
public native static void forwardMsg(int msg_ids[], int chat_ids);
public native static void forwardMsgs(int msg_ids[], int chat_ids);
private native static long MrMailboxGetMsg (long hMailbox, int id); // return hMsg which must be unref'd after usage
private native static String MrMailboxGetMsgInfo (long hMailbox, int id);
@@ -2586,19 +2586,36 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
@Override
public void didSelectDialog(DialogsActivity dialogsFragment, long chat_id, boolean param)
public void didSelectDialog(DialogsActivity dialogsFragment, long fwd_chat_id, boolean param)
{
Toast.makeText(getParentActivity(), LocaleController.getString("NotYetImplemented", R.string.NotYetImplemented), Toast.LENGTH_SHORT).show();
if( selectedMessagesIds.size()>0) {
int ids[] = new int[selectedMessagesIds.size()], i = 0;
for (HashMap.Entry<Integer, Integer> entry : selectedMessagesIds.entrySet()) {
ids[i++] = entry.getKey();
}
MrMailbox.forwardMsgs(ids, (int)fwd_chat_id);
}
if( fwd_chat_id == dialog_id ) {
dialogsFragment.finishFragment(true);
actionBar.hideActionMode();
updateVisibleRows();
}
else {
Bundle args = new Bundle();
args.putInt("chat_id", (int)fwd_chat_id);
ChatActivity fragment = new ChatActivity(args);
if( presentFragment(fragment, true /*remove last*/) ) {
if (!AndroidUtilities.isTablet()) {
removeSelfFromStack();
}
}
else {
dialogsFragment.finishFragment(false);
}
}
//MrMailbox.forwardMsg(selectedMessageIds, chat_id);
actionBar.hideActionMode();
updateVisibleRows();
dialogsFragment.finishFragment(true);
/*
/*
if (dialog_id != 0 && (forwaringMessage != null || !selectedMessagesIds.isEmpty() )) {
if (forwaringMessage != null) {
forwaringMessage = null;
@@ -134,7 +134,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (getArguments() != null) {
onlySelect = arguments.getBoolean("onlySelect", false);
onlySelectTitle = arguments.getString("onlySelectTitle");
if( onlySelectTitle.isEmpty()) {
if( onlySelectTitle==null || onlySelectTitle.isEmpty()) {
onlySelectTitle = LocaleController.getString("SelectChat", R.string.SelectChat);
}
selectAlertString = arguments.getString("selectAlertString");