Code examples for qml-friends

All the dependencies can be installed from ppa:super-friends/ppa

Installing the qtdeclarative5-friends-plugin package should bring in the necessary dependencies

/* Sending 
   http://bazaar.launchpad.net/~super-friends/qml-friends/raring/view/head:/examples/poster.qml  */
   
import Friends 0.1

FriendsDispatcher {
    id: friends
    // use this to check if the send was successfull
    onSendComplete: {
         if (success) {
             console.log ("Send completed successfully");
         } else {
             console.log ("Send failed: " + errorMessage);
         }
     }
}

Button {
    id: sendButton
    text: i18n.tr("Send")
    onClicked: {
        /* async method to send, connect to onSendComplete for success/failure */
        friends.sendAsync(entry.text);
    }
}

Getting a model of the data from Friends
http://bazaar.launchpad.net/~super-friends/qml-friends/raring/view/head:/examples/streamview.qml

/* To get a model of all posts, suitable for use in a ListView, 
   Repeater, etc */
StreamModel {
    id: streamModel 
}

/* The roleNames provided from StreamModel:
    service
    accountId
    messageId
    stream
    sender
    senderId
    senderNick
    fromMe
    timestamp
    message
    avatar
    url
    likes
    liked
    linkPicture
    linkName
    linkUrl
    linkDescription
    linkCaption
    linkIcon
    location
    latitude
    longitude
*/

/* To get a model of all images */
StreamModel { 
    stream: "images"
}

/* To get a model of content from twitter */
StreamModel { 
    service: "twitter"
}

/* To get a model of content from accountId 2 */
StreamModel { 
    account: 2
}

/* To get a model of threads on a post */
StreamModel { 
    stream: "reply_to/"+messageId
}

/* convenience function for converting timestamps into time delta 
   strings, like "2 hours ago" */
FriendsUtils {
    id: friendsUtils
}

friendsUtils.createTimeString(timestamp)

