~nmurphy/do-plugins/bibtex-plugin

« back to all changes in this revision

Viewing changes to Skype/src/User.cs

  • Committer: Alex Launi
  • Date: 2008-10-20 23:36:01 UTC
  • mfrom: (46.2.1 skype)
  • Revision ID: alex@eriktorvaldsonn-20081020233601-rjmiql15h0lv749a
Merge Chris Sziskzoy's changes to skype for contact integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
//
18
18
 
19
19
using System;
 
20
using System.Text.RegularExpressions;
20
21
using System.Collections;
21
22
using System.Collections.Generic;
22
23
 
132
133
    public override string Name {
133
134
      get { return "Start Skype Call"; }
134
135
    }
135
 
 
 
136
                
136
137
    public override string Description {
137
138
      get { return "Start a new Skype call with a contact."; }
138
139
    }
142
143
    }
143
144
    
144
145
    public override bool SupportsItem (IItem item) {
145
 
        return null != (item as ContactItem) ["skype.handle"];
 
146
                        if (item is ITextItem)
 
147
                        {
 
148
                                Match m = Regex.Match((item as ITextItem).Text,"^[+]?\\d*$");
 
149
                                if (m.Success)
 
150
                                        return true;
 
151
                                else
 
152
                                        return false;
 
153
                        }
 
154
                        else if (item is ContactItem)
 
155
                                return null != (item as ContactItem) ["skype.handle"];
 
156
                        else if (item is IContactDetailItem)
 
157
                        {
 
158
                                Match m = Regex.Match((item as IContactDetailItem).Description,"^[+]?\\d*$");
 
159
                                if (m.Success)
 
160
                                        return true;
 
161
                                else
 
162
                                        return false;
 
163
                        }
 
164
                        else return false;
146
165
    }
147
166
    
148
167
    public override Type[] SupportedItemTypes {
149
168
      get {
150
 
        return new Type[] { typeof (ContactItem) };
 
169
        return new Type[] { typeof (ContactItem), typeof (ITextItem), typeof (IContactDetailItem) };
151
170
      }
152
171
    }
153
172
 
156
175
    }
157
176
 
158
177
    public override IItem[] Perform (IItem[] items, IItem[] modItems) {
159
 
      ContactItem i = items [0] as ContactItem;
160
 
      SkypeAPI.Instance.StartCall (i ["skype.handle"]);
 
178
                        string number = "";
 
179
                        
 
180
                        if (items[0] is ITextItem)
 
181
                        {
 
182
                                number = (items[0] as ITextItem).Text;
 
183
                                if (number[0] != '+')
 
184
                                        number = "+" + number;
 
185
                                SkypeAPI.Instance.StartCall (number);
 
186
                        }
 
187
                        else if (items[0] is ContactItem)
 
188
                        {
 
189
                                ContactItem i = items [0] as ContactItem;
 
190
                                SkypeAPI.Instance.StartCall (i ["skype.handle"]);
 
191
                        }
 
192
                        else if (items[0] is IContactDetailItem)
 
193
                        {
 
194
                                IContactDetailItem i = items[0] as IContactDetailItem;
 
195
                                number = i.Description;
 
196
                                if (number[0] != '+')
 
197
                                        number = "+" + number;
 
198
                                SkypeAPI.Instance.StartCall (number);
 
199
                        }
161
200
      return null;
162
201
    }
163
202