style, make some @NunNull annotations

This commit is contained in:
B. Petersen
2018-09-21 14:25:39 +02:00
parent 26947bb865
commit c2c7a3173b
3 changed files with 162 additions and 165 deletions
+7 -5
View File
@@ -23,6 +23,8 @@
package com.b44t.messenger;
import android.support.annotation.NonNull;
public class DcChatlist {
public DcChatlist(long chatlistCPtr) {
@@ -35,11 +37,11 @@ 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 @NonNull DcChat getChat (int index) { return new DcChat(getChatCPtr(index)); }
public @NonNull DcMsg getMsg (int index) { return new DcMsg(getMsgCPtr(index)); }
public @NonNull 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
+74 -72
View File
@@ -23,6 +23,8 @@
package com.b44t.messenger;
import android.support.annotation.NonNull;
public class DcContext {
public final static int DC_EVENT_INFO = 100;
@@ -73,78 +75,78 @@ public class DcContext {
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 boolean 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 @NonNull 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 @NonNull DcChatlist getChatlist (int listflags, String query, int queryId) { return new DcChatlist(getChatlistCPtr(listflags, query, queryId)); }
public @NonNull 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 boolean 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 @NonNull 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 @NonNull 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) {
+81 -88
View File
@@ -23,6 +23,7 @@
package com.b44t.messenger;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import org.thoughtcrime.securesms.database.Address;
@@ -80,12 +81,88 @@ public class DcMsg {
return this.getId()==that.getId() && this.getId()!=0;
}
public native int getId ();
public native String getText ();
public native long getTimestamp ();
public native int getType ();
public native int getState ();
public native int getChatId ();
public native int getFromId ();
public native int getWidth (int def);
public native int getHeight (int def);
public native int getDuration ();
public native void lateFilingMediaSize(int width, int height, int duration);
public native int getBytes ();
public @NonNull DcLot getSummary (DcChat chat) { return new DcLot(getSummaryCPtr(chat.getChatCPtr())); }
public native String getSummarytext (int approx_characters);
public native int showPadlock ();
public @NonNull DcLot getMediainfo () { return new DcLot(getMediainfoCPtr()); }
public boolean hasFile () { String file = getFile(); return file!=null && !file.isEmpty(); }
public native String getFile ();
public native String getFilemime ();
public native String getFilename ();
public native boolean isForwarded ();
public native boolean isInfo ();
public native boolean isSetupMessage ();
public native String getSetupCodeBegin ();
public native boolean isIncreation ();
public native void setType (int type);
public native void setText (String text);
public native void setFile (String file, String filemime);
public native void setDimension (int width, int height);
public native void setDuration (int duration);
public native void setMediainfo (String author, String trackname);
// aliases and higher-level tools
public boolean isOutgoing() {
return getFromId() == DcContact.DC_CONTACT_ID_SELF;
}
public boolean isGroupAction() {
// TODO: check DcChat
return false;
}
public String getDisplayBody() {
return getText();
}
public String getBody() {
return getText();
}
public long getDateReceived() {
return getTimestamp();
}
public boolean isFailed() {
return getState() == DC_STATE_OUT_ERROR;
}
public long getExpiresIn() {
return -1; // never.
}
public long getExpireStarted() {
return 0;
}
public boolean isSecure() {
return showPadlock()!=0;
}
public boolean isPending() {
return getState() == DC_STATE_OUT_PENDING;
}
public boolean isMediaPending() {
return isPending();
}
public boolean isDelivered() {
return getState() == DC_STATE_OUT_DELIVERED;
}
public boolean isRemoteRead() {
return getState() == DC_STATE_OUT_MDN_RCVD;
}
public int getSubscriptionId() {
return -1;
}
public boolean isMms() {
return false;
}
@@ -97,51 +174,6 @@ public class DcMsg {
public boolean isIdentityVerified() { return false; }
public boolean isIdentityDefault() { return false; }
// aliases
public String getDisplayBody() { return getText(); }
public String getBody() { return getText(); }
public long getDateReceived() { return getTimestamp(); }
public boolean isFailed() {
return getState() == DC_STATE_OUT_ERROR;
}
public long getExpiresIn() {
return -1; // never.
}
public long getExpireStarted() {
return 0;
}
public boolean isSecure() {
return showPadlock()!=0;
}
public boolean isPending() {
return getState() == DC_STATE_OUT_PENDING;
}
public boolean isMediaPending() {
return isPending();
}
public boolean isDelivered() {
return getState() == DC_STATE_OUT_DELIVERED;
}
public boolean isRemoteRead() {
return getState() == DC_STATE_OUT_MDN_RCVD;
}
public int getSubscriptionId() {
return -1;
}
public boolean isMms() {
return false;
}
@Nullable
public Quote getQuote() {
// TODO: remove the dependency to org.thoughtcrime.securesms.database.model.Quote
@@ -154,48 +186,9 @@ public class DcMsg {
return new Recipient(Address.fromContact(getFromId()), recipientDetails);
}
public boolean hasFile() {
String file = getFile();
return file!=null && !file.isEmpty();
}
public native int getId();
public native String getText();
public native long getTimestamp();
public native int getType();
public native int getState();
public native int getChatId();
public native int getFromId();
public native int getWidth(int def);
public native int getHeight(int def);
public native int getDuration();
public native void lateFilingMediaSize(int width, int height, int duration);
public native int getBytes();
public DcLot getSummary(DcChat chat) { return new DcLot(getSummaryCPtr(chat.getChatCPtr())); }
public native String getSummarytext(int approx_characters);
public native int showPadlock();
public DcLot getMediainfo() { return new DcLot(getMediainfoCPtr()); }
public native String getFile();
public native String getFilemime();
public native String getFilename();
public native boolean isForwarded();
public native boolean isInfo();
public native boolean isSetupMessage();
public native String getSetupCodeBegin();
public native boolean isIncreation();
public native void setType(int type);
public native void setText(String text);
public native void setFile(String file, String filemime);
public native void setDimension(int width, int height);
public native void setDuration(int duration);
public native void setMediainfo(String author, String trackname);
// working with raw c-data
private long msgCPtr; // CAVE: the name is referenced in the JNI
private native void unrefMsgCPtr();
private native long getSummaryCPtr(long chatCPtr);
private long msgCPtr; // CAVE: the name is referenced in the JNI
private native void unrefMsgCPtr ();
private native long getSummaryCPtr (long chatCPtr);
private native long getMediainfoCPtr();
};