mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-06 03:50:08 +02:00
Add OS-native file.
This commit is contained in:
parent
33b87fb2d9
commit
02801bc71d
3 changed files with 128 additions and 5 deletions
|
@ -23,11 +23,6 @@
|
|||
* Authors: Björn Petersen
|
||||
* Purpose: Reading from IMAP servers, see header for details.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* TODO: On Android, I think, the thread must be marked using
|
||||
* AttachCurrentThread(), see MailCore2 code and https://developer.android.com/training/articles/perf-jni.html
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
@ -37,6 +32,7 @@
|
|||
|
||||
#include "mrmailbox.h"
|
||||
#include "mrimap.h"
|
||||
#include "mrosnative.h"
|
||||
|
||||
|
||||
class MrImapThreadVal
|
||||
|
@ -297,7 +293,15 @@ WorkingThread_Exit:
|
|||
|
||||
void MrImap::StartupHelper(MrImap* imap) // static function
|
||||
{
|
||||
#if defined(__ANDROID) || defined(ANDROID)
|
||||
MrAndroidSetupThread();
|
||||
#endif
|
||||
|
||||
imap->WorkingThread();
|
||||
|
||||
#if defined(__ANDROID) || defined(ANDROID)
|
||||
MrAndroidUnsetupThread();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
78
src/mrosnative.cpp
Normal file
78
src/mrosnative.cpp
Normal file
|
@ -0,0 +1,78 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
* Messenger Backend
|
||||
* 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: mrosnative.cpp
|
||||
* Authors: Björn Petersen
|
||||
* Purpose: JNI handling, see header for details.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "mrmailbox.h"
|
||||
#include "mrosnative.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Android Natives
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#if defined(__ANDROID) || defined(ANDROID)
|
||||
|
||||
|
||||
static JavaVM* s_jvm = NULL; // TODO: how is this set up?
|
||||
static jint s_version = 0;
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_libmailcore_MainThreadUtils_setupNative(JNIEnv * env, jobject object)
|
||||
{
|
||||
// AutoreleasePool * pool = new AutoreleasePool();
|
||||
|
||||
env->GetJavaVM(&s_jvm);
|
||||
s_version = env->GetVersion();
|
||||
//s_mainThreadUtils = reinterpret_cast<jobject>(env->NewGlobalRef(object));
|
||||
//jclass localClass = env->FindClass("com/libmailcore/MainThreadUtils");
|
||||
//s_mainThreadUtilsClass = reinterpret_cast<jclass>(env->NewGlobalRef(localClass));
|
||||
//MCAssert(s_mainThreadUtilsClass != NULL);
|
||||
//MCTypesUtilsInit();
|
||||
|
||||
//pool->release();
|
||||
}
|
||||
|
||||
|
||||
void MrAndroidSetupThread(void)
|
||||
{
|
||||
assert(s_jvm);;
|
||||
|
||||
JNIEnv* env = NULL;
|
||||
s_jvm->AttachCurrentThread(&env, NULL);
|
||||
}
|
||||
|
||||
|
||||
void MrAndroidUnsetupThread(void)
|
||||
{
|
||||
s_jvm->DetachCurrentThread();
|
||||
}
|
||||
|
||||
|
||||
#endif // defined(__ANDROID) || defined(ANDROID)
|
41
src/mrosnative.h
Normal file
41
src/mrosnative.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
* Messenger Backend
|
||||
* 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: mrosnative.h
|
||||
* Authors: Björn Petersen
|
||||
* Purpose: OS-native depending part, eg. for attaching threads in JNI
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef __MROSNATIVE_H__
|
||||
#define __MROSNATIVE_H__
|
||||
|
||||
|
||||
#if defined(__ANDROID) || defined(ANDROID)
|
||||
|
||||
void MrAndroidSetupThread(void);
|
||||
void MrAndroidUnsetupThread(void);
|
||||
|
||||
#endif // defined(__ANDROID) || defined(ANDROID)
|
||||
|
||||
|
||||
#endif // __MROSNATIVE_H__
|
Loading…
Add table
Add a link
Reference in a new issue