~b-muskalla/do-plugins/do-plugins

« back to all changes in this revision

Viewing changes to Skype/src/Skype.cs

  • Committer: Benjamin Muskalla
  • Date: 2013-02-02 17:32:52 UTC
  • Revision ID: b.muskalla@gmail.com-20130202173252-4x1dy6lhhu3gges2
Fix to find Skype contacts

Instead of querying all groups, simply issue a query on all available
friends as groups can be empty or cannot be returned in newer Skype
versions.

Related bug: 781553

Show diffs side-by-side

added added

removed removed

Lines of Context:
177
177
                {
178
178
                        request = string.Format (request, args);
179
179
                        string reply = SkypeObject.Invoke (string.Format ("GET {0}", request));
180
 
                        if (!reply.StartsWith ("ERROR"))
 
180
                        if (!reply.StartsWith ("ERROR") && reply.Length != 0)
181
181
                                return reply.Substring (request.Length).Trim ();
182
182
                        Log<Skype>.Warn ("Skype failed for {0}", request);
183
183
                        Log<Skype>.Debug ("Skype replied with: {0}", reply);
203
203
                                                yield break;
204
204
                                }
205
205
                                
206
 
                                IEnumerable<string> groups = SkypeObject.Invoke ("SEARCH GROUPS ALL") .Substring (7).Split (new [] {','});
207
 
 
208
 
                                string onlineGroup = groups.FirstOrDefault (g => 
209
 
                                    SkypeObject.Invoke (string.Format ("GET GROUP {0} TYPE", g.Trim ())).Contains ("SKYPE_FRIENDS"));
210
 
                                
211
 
                                if (string.IsNullOrEmpty (onlineGroup)) {
212
 
                                        Log<Skype>.Error ("Could not find online group.");
213
 
                                        groups.ForEach (g => {
214
 
                                                Log<Skype>.Debug (SkypeObject.Invoke (string.Format ("GET GROUP {0} TYPE", g.Trim())));
215
 
                                        } );
216
 
                                        yield break;
217
 
                                }
218
 
                                
219
 
                                string handlesReply = Skype.Get ("GROUP {0} USERS", onlineGroup);
220
 
 
221
 
                                if (handlesReply.StartsWith ("ERROR")) {
222
 
                                        Log<Skype>.Error ("Could not fetch friend handles.");
223
 
                                        Log<Skype>.Debug ("Skype returned: {0}", handlesReply);
224
 
                                }
225
 
                                
226
 
                                IEnumerable<string> handles = handlesReply.Split (new [] {','});
227
 
 
228
 
                                foreach (string handle in handles)
229
 
                                        yield return handle.Trim ();
230
 
                                  
 
206
                                IEnumerable<string> handles = SkypeObject.Invoke ("SEARCH FRIENDS").Split (new [] {','});
 
207
 
 
208
                                foreach (string handle in handles) {
 
209
                                        if(handle.Trim ().Length != 0)
 
210
                                                yield return handle.Trim ();
 
211
                                }              
231
212
                                yield break;
232
213
                        }
233
214
                }