~ken-vandine/gwibber/features_api

« back to all changes in this revision

Viewing changes to qml/Post.qml

  • Committer: Ken VanDine
  • Date: 2013-03-19 23:14:41 UTC
  • Revision ID: ken.vandine@canonical.com-20130319231441-lnmnkg45zhw2gdws
use the features API to get list of accounts to send too

Show diffs side-by-side

added added

removed removed

Lines of Context:
108
108
            running: visible
109
109
        }
110
110
    }
111
 
/* FIXME: We need to iterate the checked accounts and use friends.sendForAccount */
 
111
 
112
112
    AccountServiceModel {
113
113
        id: accounts
114
114
        serviceType: "microblogging"
117
117
                var displayName = accounts.get(i, "displayName");
118
118
                var accountId = accounts.get(i, "accountId");
119
119
                var serviceName = accounts.get(i, "serviceName");
120
 
                accountsModel.append({"displayName": displayName, "id": accountId, "provider": serviceName, "iconName": serviceName.toLowerCase().replace(".",""), "sendEnabled": false});
 
120
                var features = friends.featuresForProtocol(serviceName.toLowerCase().replace(".",""));
 
121
                if (features.indexOf("send") > -1) {
 
122
                    console.log (serviceName + " Supports send");
 
123
                    /* FIXME: we should get the iconName and serviceName from the accountService
 
124
                       but I am not sure we can access that from JS */
 
125
                    accountsModel.append({
 
126
                        "displayName": displayName,
 
127
                        "id": accountId,
 
128
                        "provider": serviceName,
 
129
                        "iconName": serviceName.toLowerCase().replace(".",""),
 
130
                        "sendEnabled": true
 
131
                    });
 
132
                }
121
133
            }
122
134
        }
123
135
    }
126
138
        id: accountsModel
127
139
    }
128
140
 
129
 
    //FIXME: we should cache features and use that instead of hard coded list
130
 
    function can_send(p) {
131
 
        return p.toLowerCase() == "facebook" || p.toLowerCase() == "twitter" || p.toLowerCase().replace(".","") == "identica";
132
 
    }
133
 
 
134
141
    Item {
135
142
        id: accountsArea
136
143
        width: parent.width
153
160
                        text: displayName
154
161
                        opacity: sw.checked ? 1.0 : 0.3
155
162
 
156
 
                        visible: can_send(provider)
157
163
                        height: visible ? icon.height : 0
158
164
                        icon: UbuntuShape {
159
165
                            id: icon
168
174
                        control {
169
175
                            Switch {
170
176
                                id: sw
171
 
                                checked: can_send(provider)
 
177
                                checked: sendEnabled
172
178
                                onCheckedChanged: {
173
179
                                    accountsModel.setProperty(index, "sendEnabled", sw.checked);
174
180
                                }