style Dc-native classes, leaving out DcMsg as this is pending with other changes in the 'conversation' branch

This commit is contained in:
B. Petersen
2018-09-16 11:49:08 +02:00
parent ae63b61132
commit ac6e1a23da
5 changed files with 157 additions and 160 deletions
+17 -20
View File
@@ -23,11 +23,11 @@ package com.b44t.messenger;
public class DcChat {
public final static int DC_CHAT_ID_DEADDROP = 1;
public final static int DC_CHAT_ID_STARRED = 5;
public final static int DC_CHAT_ID_DEADDROP = 1;
public final static int DC_CHAT_ID_STARRED = 5;
public final static int DC_CHAT_ID_ARCHIVED_LINK = 6;
public final static int DC_CHAT_ID_ALLDONE_HINT = 7;
public final static int DC_CHAT_ID_LAST_SPECIAL = 9;
public final static int DC_CHAT_ID_ALLDONE_HINT = 7;
public final static int DC_CHAT_ID_LAST_SPECIAL = 9;
public DcChat(long chatCPtr) {
this.chatCPtr = chatCPtr;
@@ -39,23 +39,20 @@ public class DcChat {
chatCPtr = 0;
}
public native int getId();
public native boolean isGroup();
public native int getArchived();
public native String getName();
public native String getSubtitle();
public native String getProfileImage();
public native boolean isUnpromoted();
public native boolean isSelfTalk();
public native boolean isVerified();
public native String getDraft();
public native long getDraftTimestamp();
public native int getId ();
public native boolean isGroup ();
public native int getArchived ();
public native String getName ();
public native String getSubtitle ();
public native String getProfileImage ();
public native boolean isUnpromoted ();
public native boolean isSelfTalk ();
public native boolean isVerified ();
public native String getDraft ();
public native long getDraftTimestamp ();
// working with raw c-data
private long chatCPtr; // CAVE: the name is referenced in the JNI
private long chatCPtr; // CAVE: the name is referenced in the JNI
private native void unrefChatCPtr();
public long getChatCPtr() {
return chatCPtr;
}
public long getChatCPtr () { return chatCPtr; }
}
+9 -9
View File
@@ -35,16 +35,16 @@ public class DcChatlist {
chatlistCPtr = 0;
}
public native int getCnt();
public native int getChatId(int index);
public DcChat getChat(int index) { return new DcChat(getChatCPtr(index)); }
public DcMsg getMsg(int index) { return new DcMsg(getMsgCPtr(index)); }
public DcLot getSummary(int index, DcChat chat) { return new DcLot(getSummaryCPtr(index, chat==null? null : chat.getChatCPtr())); }
public native int getCnt ();
public native int getChatId (int index);
public DcChat getChat (int index) { return new DcChat(getChatCPtr(index)); }
public DcMsg getMsg (int index) { return new DcMsg(getMsgCPtr(index)); }
public DcLot getSummary(int index, DcChat chat) { return new DcLot(getSummaryCPtr(index, chat==null? null : chat.getChatCPtr())); }
// working with raw c-data
private long chatlistCPtr; // CAVE: the name is referenced in the JNI
private long chatlistCPtr; // CAVE: the name is referenced in the JNI
private native void unrefChatlistCPtr();
private native long getChatCPtr(int index);
private native long getMsgCPtr(int index);
private native long getSummaryCPtr(int index, long chatCPtr);
private native long getChatCPtr (int index);
private native long getMsgCPtr (int index);
private native long getSummaryCPtr (int index, long chatCPtr);
}
+10 -10
View File
@@ -40,16 +40,16 @@ public class DcContact {
contactCPtr = 0;
}
public native int getId ();
public native String getName ();
public native String getDisplayName ();
public native String getFirstName ();
public native String getAddr ();
public native String getNameNAddr ();
public native boolean isBlocked ();
public native boolean isVerified ();
public native int getId ();
public native String getName ();
public native String getDisplayName();
public native String getFirstName ();
public native String getAddr ();
public native String getNameNAddr ();
public native boolean isBlocked ();
public native boolean isVerified ();
// working with raw c-data
private long contactCPtr; // CAVE: the name is referenced in the JNI
private native void unrefContactCPtr ();
private long contactCPtr; // CAVE: the name is referenced in the JNI
private native void unrefContactCPtr();
}
+112 -112
View File
@@ -25,126 +25,126 @@ package com.b44t.messenger;
public class DcContext {
public final static int DC_EVENT_INFO = 100;
public final static int DC_EVENT_WARNING = 300;
public final static int DC_EVENT_ERROR = 400;
public final static int DC_EVENT_MSGS_CHANGED = 2000;
public final static int DC_EVENT_INCOMING_MSG = 2005;
public final static int DC_EVENT_MSG_DELIVERED = 2010;
public final static int DC_EVENT_MSG_FAILED = 2012;
public final static int DC_EVENT_MSG_READ = 2015;
public final static int DC_EVENT_CHAT_MODIFIED = 2020;
public final static int DC_EVENT_CONTACTS_CHANGED = 2030;
public final static int DC_EVENT_CONFIGURE_PROGRESS = 2041;
public final static int DC_EVENT_IMEX_PROGRESS = 2051;
public final static int DC_EVENT_IMEX_FILE_WRITTEN = 2052;
public final static int DC_EVENT_INFO = 100;
public final static int DC_EVENT_WARNING = 300;
public final static int DC_EVENT_ERROR = 400;
public final static int DC_EVENT_MSGS_CHANGED = 2000;
public final static int DC_EVENT_INCOMING_MSG = 2005;
public final static int DC_EVENT_MSG_DELIVERED = 2010;
public final static int DC_EVENT_MSG_FAILED = 2012;
public final static int DC_EVENT_MSG_READ = 2015;
public final static int DC_EVENT_CHAT_MODIFIED = 2020;
public final static int DC_EVENT_CONTACTS_CHANGED = 2030;
public final static int DC_EVENT_CONFIGURE_PROGRESS = 2041;
public final static int DC_EVENT_IMEX_PROGRESS = 2051;
public final static int DC_EVENT_IMEX_FILE_WRITTEN = 2052;
public final static int DC_EVENT_SECUREJOIN_INVITER_PROGRESS = 2060;
public final static int DC_EVENT_SECUREJOIN_JOINER_PROGRESS = 2061;
public final static int DC_EVENT_IS_OFFLINE = 2081;
public final static int DC_EVENT_GET_STRING = 2091;
public final static int DC_EVENT_GET_QUANTITIY_STRING = 2092;
public final static int DC_EVENT_HTTP_GET = 2100;
public final static int DC_EVENT_SECUREJOIN_JOINER_PROGRESS = 2061;
public final static int DC_EVENT_IS_OFFLINE = 2081;
public final static int DC_EVENT_GET_STRING = 2091;
public final static int DC_EVENT_GET_QUANTITIY_STRING = 2092;
public final static int DC_EVENT_HTTP_GET = 2100;
public final static int DC_IMEX_EXPORT_SELF_KEYS = 1;
public final static int DC_IMEX_IMPORT_SELF_KEYS = 2;
public final static int DC_IMEX_EXPORT_BACKUP = 11;
public final static int DC_IMEX_IMPORT_BACKUP = 12;
public final static int DC_IMEX_EXPORT_BACKUP = 11;
public final static int DC_IMEX_IMPORT_BACKUP = 12;
public final static int DC_GCL_VERIFIED_ONLY = 1;
public final static int DC_GCL_ADD_SELF = 2;
public final static int DC_GCL_ARCHIVED_ONLY = 0x01;
public final static int DC_GCL_NO_SPECIALS = 0x02;
public final static int DC_GCL_VERIFIED_ONLY = 1;
public final static int DC_GCL_ADD_SELF = 2;
public final static int DC_GCL_ARCHIVED_ONLY = 0x01;
public final static int DC_GCL_NO_SPECIALS = 0x02;
public final static int DC_GCL_ADD_ALLDONE_HINT = 0x04;
public final static int DC_GCM_ADDDAYMARKER = 0x01;
public final static int DC_QR_ASK_VERIFYCONTACT = 200;
public final static int DC_QR_ASK_VERIFYGROUP = 202;
public final static int DC_QR_FPR_OK = 210;
public final static int DC_QR_FPR_MISMATCH = 220;
public final static int DC_QR_FPR_WITHOUT_ADDR = 230;
public final static int DC_QR_ADDR = 320;
public final static int DC_QR_TEXT = 330;
public final static int DC_QR_URL = 332;
public final static int DC_QR_ERROR = 400;
public final static int DC_QR_ASK_VERIFYGROUP = 202;
public final static int DC_QR_FPR_OK = 210;
public final static int DC_QR_FPR_MISMATCH = 220;
public final static int DC_QR_FPR_WITHOUT_ADDR = 230;
public final static int DC_QR_ADDR = 320;
public final static int DC_QR_TEXT = 330;
public final static int DC_QR_URL = 332;
public final static int DC_QR_ERROR = 400;
public DcContext(String osName) {
handleEvent(0,0,0); // call handleEvent() to make sure it is not optimized away and JNI won't find it
contextCPtr = createContextCPtr(osName);
}
public native int open(String dbfile);
public native void close();
public native String getBlobdir();
public native void configure();
public native void stopOngoingProcess();
public native int isConfigured();
public native void performJobs();
public native void fetch();
public native void idle();
public native void interruptIdle();
public native void performSmtpJobs();
public native void performSmtpIdle();
public native void interruptSmtpIdle();
public native void setConfig(String key, String value);
public native void setConfigInt(String key, int value);
public native String getConfig(String key, String def);
public native int getConfigInt(String key, int def);
public native String getInfo();
public native String cmdline(String cmd);
public native String initiateKeyTransfer();
public native boolean continueKeyTransfer(int msg_id, String setup_code);
public native void imex(int what, String dir);
public native String imexHasBackup(String dir);
public native int checkPassword(String pw);
public native boolean mayBeValidAddr(String addr);
public native int lookupContactIdByAddr(String addr);
public native int[] getContacts(int flags, String query);
public native int getBlockedCount();
public native int[] getBlockedContacts();
public DcContact getContact(int contact_id) { return new DcContact(getContactCPtr(contact_id)); }
public native int createContact(String name, String addr);
public native void blockContact(int id, int block);
public native String getContactEncrInfo(int contact_id);
public native int deleteContact(int id);
public native int addAddressBook(String adrbook);
public DcChatlist getChatlist(int listflags, String query, int queryId) { return new DcChatlist(getChatlistCPtr(listflags, query, queryId)); }
public DcChat getChat(int chat_id) { return new DcChat(getChatCPtr(chat_id)); }
public native void markseenMsgs(int msg_ids[]);
public native void marknoticedChat(int chat_id);
public native void marknoticedAllChats();
public native void marknoticedContact(int contact_id);
public native void archiveChat(int chat_id, int archive);
public native int getChatIdByContactId(int contact_id);
public native int createChatByContactId(int contact_id);
public native int createChatByMsgId(int msg_id);
public native int createGroupChat(boolean verified, String name);
public native int isContactInChat(int chat_id, int contact_id);
public native int addContactToChat(int chat_id, int contact_id);
public native int removeContactFromChat(int chat_id, int contact_id);
public native void setDraft(int chat_id, String draft/*NULL=delete*/);
public native int setChatName(int chat_id, String name);
public native int setChatProfileImage(int chat_id, String name);
public native int[] getChatMsgs(int chat_id, int flags, int marker1before);
public native int[] searchMsgs(int chat_id, String query);
public native int[] getFreshMsgs();
public native int[] getChatMedia(int chat_id, int msg_type, int or_msg_type);
public native int getNextMedia(int msg_id, int dir);
public native int[] getChatContacts(int chat_id);
public native void deleteChat(int chat_id);
public DcMsg getMsg(int msg_id) { return new DcMsg(getMsgCPtr(msg_id)); }
public native String getMsgInfo(int id);
public native int getFreshMsgCount(int chat_id);
public native void deleteMsgs(int msg_ids[]);
public native void forwardMsgs(int msg_ids[], int chat_ids);
public native int sendMsg(int chat_id, DcMsg msg);
public native int sendTextMsg(int chat_id, String text);
public native int sendVcardMsg(int chat_id, int contact_id);
public native int sendMediaMsg(int chat_id, int type, String file, String mime, int w, int h, int time_ms, String author, String trackname);
public native int checkQrCPtr(String qr);
public DcLot checkQr(String qr) { return new DcLot(checkQrCPtr(qr)); }
public native String getSecurejoinQr(int chat_id);
public native int joinSecurejoin(String qr);
public native int open (String dbfile);
public native void close ();
public native String getBlobdir ();
public native void configure ();
public native void stopOngoingProcess ();
public native int isConfigured ();
public native void performJobs ();
public native void fetch ();
public native void idle ();
public native void interruptIdle ();
public native void performSmtpJobs ();
public native void performSmtpIdle ();
public native void interruptSmtpIdle ();
public native void setConfig (String key, String value);
public native void setConfigInt (String key, int value);
public native String getConfig (String key, String def);
public native int getConfigInt (String key, int def);
public native String getInfo ();
public native String cmdline (String cmd);
public native String initiateKeyTransfer ();
public native boolean continueKeyTransfer (int msg_id, String setup_code);
public native void imex (int what, String dir);
public native String imexHasBackup (String dir);
public native int checkPassword (String pw);
public native boolean mayBeValidAddr (String addr);
public native int lookupContactIdByAddr(String addr);
public native int[] getContacts (int flags, String query);
public native int getBlockedCount ();
public native int[] getBlockedContacts ();
public DcContact getContact (int contact_id) { return new DcContact(getContactCPtr(contact_id)); }
public native int createContact (String name, String addr);
public native void blockContact (int id, int block);
public native String getContactEncrInfo (int contact_id);
public native int deleteContact (int id);
public native int addAddressBook (String adrbook);
public DcChatlist getChatlist (int listflags, String query, int queryId) { return new DcChatlist(getChatlistCPtr(listflags, query, queryId)); }
public DcChat getChat (int chat_id) { return new DcChat(getChatCPtr(chat_id)); }
public native void markseenMsgs (int msg_ids[]);
public native void marknoticedChat (int chat_id);
public native void marknoticedAllChats ();
public native void marknoticedContact (int contact_id);
public native void archiveChat (int chat_id, int archive);
public native int getChatIdByContactId (int contact_id);
public native int createChatByContactId(int contact_id);
public native int createChatByMsgId (int msg_id);
public native int createGroupChat (boolean verified, String name);
public native int isContactInChat (int chat_id, int contact_id);
public native int addContactToChat (int chat_id, int contact_id);
public native int removeContactFromChat(int chat_id, int contact_id);
public native void setDraft (int chat_id, String draft/*null=delete*/);
public native int setChatName (int chat_id, String name);
public native int setChatProfileImage (int chat_id, String name);
public native int[] getChatMsgs (int chat_id, int flags, int marker1before);
public native int[] searchMsgs (int chat_id, String query);
public native int[] getFreshMsgs ();
public native int[] getChatMedia (int chat_id, int msg_type, int or_msg_type);
public native int getNextMedia (int msg_id, int dir);
public native int[] getChatContacts (int chat_id);
public native void deleteChat (int chat_id);
public DcMsg getMsg (int msg_id) { return new DcMsg(getMsgCPtr(msg_id)); }
public native String getMsgInfo (int id);
public native int getFreshMsgCount (int chat_id);
public native void deleteMsgs (int msg_ids[]);
public native void forwardMsgs (int msg_ids[], int chat_ids);
public native int sendMsg (int chat_id, DcMsg msg);
public native int sendTextMsg (int chat_id, String text);
public native int sendVcardMsg (int chat_id, int contact_id);
public native int sendMediaMsg (int chat_id, int type, String file, String mime, int w, int h, int time_ms, String author, String trackname);
public native int checkQrCPtr (String qr);
public DcLot checkQr (String qr) { return new DcLot(checkQrCPtr(qr)); }
public native String getSecurejoinQr (int chat_id);
public native int joinSecurejoin (String qr);
// event handling - you should @Override this function in derived classes
public long handleEvent(int event, long data1, long data2) {
@@ -154,15 +154,15 @@ public class DcContext {
// helper to get/return strings from/to handleEvent()
public native static boolean data1IsString(int event);
public native static boolean data2IsString(int event);
public native static String dataToString(long data);
public native static long stringToData(String str);
public native static String dataToString (long data);
public native static long stringToData (String str);
// working with raw c-data
private long contextCPtr; // CAVE: the name is referenced in the JNI
private long contextCPtr; // CAVE: the name is referenced in the JNI
private native long createContextCPtr(String osName);
public native long createMsgCPtr();
private native long getChatlistCPtr(int listflags, String query, int queryId);
private native long getChatCPtr(int chat_id);
private native long getMsgCPtr(int id);
private native long getContactCPtr(int id);
public native long createMsgCPtr ();
private native long getChatlistCPtr (int listflags, String query, int queryId);
private native long getChatCPtr (int chat_id);
private native long getMsgCPtr (int id);
private native long getContactCPtr (int id);
}
+9 -9
View File
@@ -25,9 +25,9 @@ package com.b44t.messenger;
public class DcLot {
public final static int DC_TEXT1_DRAFT = 1;
public final static int DC_TEXT1_DRAFT = 1;
public final static int DC_TEXT1_USERNAME = 2;
public final static int DC_TEXT1_SELF = 3;
public final static int DC_TEXT1_SELF = 3;
public DcLot(long lotCPtr) {
this.lotCPtr = lotCPtr;
@@ -39,14 +39,14 @@ public class DcLot {
lotCPtr = 0;
}
public native String getText1();
public native int getText1Meaning();
public native String getText2();
public native long getTimestamp();
public native int getState();
public native int getId();
public native String getText1 ();
public native int getText1Meaning();
public native String getText2 ();
public native long getTimestamp ();
public native int getState ();
public native int getId ();
// working with raw c-data
private long lotCPtr; // CAVE: the name is referenced in the JNI
private long lotCPtr; // CAVE: the name is referenced in the JNI
private native void unrefLotCPtr();
}