Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conversations: remember last seen timestamps #30

Merged
merged 1 commit into from
Jul 28, 2020
Merged

Conversation

aviau
Copy link
Member

@aviau aviau commented Jul 27, 2020

Or user won't see the message.

@aviau aviau force-pushed the aviau/conversation branch from 135af84 to ff7b510 Compare July 27, 2020 19:43
@aviau
Copy link
Member Author

aviau commented Jul 27, 2020

@isra17 review plz

@aviau aviau force-pushed the aviau/conversation branch 2 times, most recently from 407602f to d0af981 Compare July 28, 2020 01:43
@aviau
Copy link
Member Author

aviau commented Jul 28, 2020

ping @isra17!

After our discussion, I have implemented persistent timestamps.

It looks like this in the buddylist:

            <chat proto='prpl-flare-icq' account='+censored'>
                <alias>Salut</alias>
                <component name='group'>Conferences</component>
                <component name='title'>Salut</component>
                <component name='state'>joined</component>
                <component name='sn'>[email protected]</component>
                <setting name='gtk-mute-sound' type='bool'>0</setting>
                <setting name='last_seen_timestamp' type='string'>1576258436</setting>
            </chat>

I use strings for the timestamp because they are int64.

@aviau aviau force-pushed the aviau/conversation branch from d0af981 to 4b87661 Compare July 28, 2020 13:58
pub fn get_string(&mut self, c_key: &CString) -> Option<String> {
let c_str =
unsafe { purple_sys::purple_blist_node_get_string(self.0.as_ptr(), c_key.as_ptr()) };
if c_str.is_null() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

            NonNull::new(c_str)
            .map(|p| {
                CStr::from_ptr(p.as_ptr() as *const c_char)
                    .to_str()
                    .unwrap()
            })

? (This would return an Option<&str>)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't seem to create the NonNull with the c_value.

Am I doing something wrong?

    pub fn get_string(&mut self, key: &str) -> Option<&str> {
        let c_key = CString::new(key).unwrap();
        let mut c_value =
            unsafe { purple_sys::purple_blist_node_get_string(self.0.as_ptr(), c_key.as_ptr()) };

        NonNull::new(c_value).map(|p| {
            CStr::from_ptr(p.as_ptr() as *const c_char)
                .to_str()
                .unwrap()
        })
    }
   = note: expected raw pointer `*mut _`
              found raw pointer `*const i8`

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add NonNull::new(c_value as *mut c_char) I believe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@aviau aviau force-pushed the aviau/conversation branch from 4b87661 to cecccf3 Compare July 28, 2020 14:55
@aviau aviau changed the title poller: create conversation on new messages conversations: remember last seen timestamps Jul 28, 2020
@aviau aviau force-pushed the aviau/conversation branch 2 times, most recently from 68797cf to f8d1cc8 Compare July 28, 2020 17:28
@aviau aviau force-pushed the aviau/conversation branch from f8d1cc8 to 5653397 Compare July 28, 2020 17:30
@isra17
Copy link
Member

isra17 commented Jul 28, 2020

LGTM!

@aviau aviau merged commit 2b8c228 into master Jul 28, 2020
@aviau aviau deleted the aviau/conversation branch July 28, 2020 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants