mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2026-08-20 21:03:08 +00:00
Full sync is now fixed
Full sync was previously not really good, Sms were ordered by date DESC, then the last date was good and when multiple loop iterations occurs, only 1 iteration happened SmsBuffer now owns LastMessageDate instead of AndroidSmsFetcher Full sync is now owned by AsyncsmsSync instead of MainActivity Last message date is more accurate and less error prone
This commit is contained in:
@@ -31,6 +31,7 @@ JNINativeMethod SmsBuffer::methods[] =
|
||||
DECL_JNIMETHOD(deleteNativeObject, "()V")
|
||||
DECL_JNIMETHOD(empty, "()Z")
|
||||
DECL_JNIMETHOD(asRawJsonString, "()Ljava/lang/String;")
|
||||
DECL_JNIMETHOD(getLastMessageDate, "()J")
|
||||
DECL_JNIMETHOD(push,
|
||||
"(IIIJLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V")
|
||||
DECL_JNIMETHOD(print, "()V")
|
||||
@@ -69,6 +70,7 @@ void SmsBuffer::reset_buffer()
|
||||
m_buffer.clear();
|
||||
m_buffer_empty = true;
|
||||
m_sms_count = 0;
|
||||
m_last_message_date = 0;
|
||||
}
|
||||
|
||||
void SmsBuffer::push(JNIEnv *env, jobject self, jint msg_id, jint mailbox_id, jint type,
|
||||
@@ -94,15 +96,19 @@ void SmsBuffer::_push(int msg_id, int mailbox_id, int type,
|
||||
m_buffer_empty = false;
|
||||
}
|
||||
|
||||
m_buffer << "{\"_id\": " << msg_id << ", "
|
||||
<< "\"mbox\": " << mailbox_id << ", "
|
||||
<< "\"type\": " << type << ", "
|
||||
<< "\"date\": " << date << ", "
|
||||
<< "\"body\": " << json::escape_string(body) << ", "
|
||||
<< "\"address\": " << json::escape_string(address) << ", "
|
||||
<< "\"read\": " << json::escape_string(read) << ", "
|
||||
<< "\"seen\": " << json::escape_string(seen)
|
||||
m_buffer << "{\"_id\":" << msg_id << ","
|
||||
<< "\"mbox\":" << mailbox_id << ","
|
||||
<< "\"type\":" << type << ","
|
||||
<< "\"date\":" << date << ","
|
||||
<< "\"body\":" << json::escape_string(body) << ","
|
||||
<< "\"address\":" << json::escape_string(address) << ","
|
||||
<< "\"read\":" << json::escape_string(read) << ","
|
||||
<< "\"seen\":" << json::escape_string(seen)
|
||||
<< "}";
|
||||
|
||||
if (date > m_last_message_date) {
|
||||
m_last_message_date = date;
|
||||
}
|
||||
m_sms_count++;
|
||||
}
|
||||
|
||||
@@ -142,4 +148,15 @@ void SmsBuffer::as_raw_json_string(std::string &result)
|
||||
std::stringstream ss;
|
||||
ss << "{\"smsCount\": " << m_sms_count << ", \"smsDatas\": " << m_buffer.str() << "]}";
|
||||
result = ss.str();
|
||||
}
|
||||
|
||||
jlong SmsBuffer::getLastMessageDate(JNIEnv *env, jobject self)
|
||||
{
|
||||
SMSBUFFER_CAST
|
||||
return me->_get_last_message_date();
|
||||
}
|
||||
|
||||
long long SmsBuffer::_get_last_message_date() const
|
||||
{
|
||||
return m_last_message_date;
|
||||
}
|
||||
@@ -59,6 +59,13 @@ public:
|
||||
JNIEXPORT static jstring JNICALL asRawJsonString(JNIEnv *env, jobject self);
|
||||
void as_raw_json_string(std::string &result);
|
||||
|
||||
/*
|
||||
* getLastMessageDate method
|
||||
*/
|
||||
|
||||
JNIEXPORT static jlong JNICALL getLastMessageDate(JNIEnv *env, jobject self);
|
||||
long long _get_last_message_date() const;
|
||||
|
||||
DECL_JNICLASSATTRS
|
||||
|
||||
private:
|
||||
@@ -66,6 +73,7 @@ private:
|
||||
std::stringstream m_buffer;
|
||||
uint32_t m_sms_count{0};
|
||||
bool m_buffer_empty{true};
|
||||
long long m_last_message_date{0};
|
||||
|
||||
static bool gJava_inited;
|
||||
static jfieldID gJava_mHandle;
|
||||
|
||||
Reference in New Issue
Block a user