PageRenderTime 39ms CodeModel.GetById 2ms app.highlight 30ms RepoModel.GetById 1ms app.codeStats 0ms

/src/org/sipdroid/sipua/SipdroidEngine.java

https://github.com/sortir/sipdroid
Java | 606 lines | 496 code | 76 blank | 34 comment | 164 complexity | 91584f9d3b3e60c2b145504487c1b5cf MD5 | raw file
  1/*
  2 * Copyright (C) 2009 The Sipdroid Open Source Project
  3 * Copyright (C) 2008 Hughes Systique Corporation, USA (http://www.hsc.com)
  4 * 
  5 * This file is part of Sipdroid (http://www.sipdroid.org)
  6 * 
  7 * Sipdroid is free software; you can redistribute it and/or modify
  8 * it under the terms of the GNU General Public License as published by
  9 * the Free Software Foundation; either version 3 of the License, or
 10 * (at your option) any later version.
 11 * 
 12 * This source code is distributed in the hope that it will be useful,
 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15 * GNU General Public License for more details.
 16 * 
 17 * You should have received a copy of the GNU General Public License
 18 * along with this source code; if not, write to the Free Software
 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 20 */
 21
 22package org.sipdroid.sipua;
 23
 24import java.io.IOException;
 25import java.net.UnknownHostException;
 26
 27import org.sipdroid.net.KeepAliveSip;
 28import org.sipdroid.sipua.ui.ChangeAccount;
 29import org.sipdroid.sipua.ui.Logger;
 30import org.sipdroid.sipua.ui.LoopAlarm;
 31import org.sipdroid.sipua.ui.Receiver;
 32import org.sipdroid.sipua.ui.Settings;
 33import org.sipdroid.sipua.ui.Sipdroid;
 34import org.zoolu.net.IpAddress;
 35import org.zoolu.net.SocketAddress;
 36import org.zoolu.sip.address.NameAddress;
 37import org.zoolu.sip.provider.SipProvider;
 38import org.zoolu.sip.provider.SipStack;
 39
 40import android.content.Context;
 41import android.content.SharedPreferences.Editor;
 42import android.net.Uri;
 43import android.net.wifi.WifiManager;
 44import android.os.Build;
 45import android.os.PowerManager;
 46import android.os.SystemClock;
 47import android.preference.PreferenceManager;
 48
 49public class SipdroidEngine implements RegisterAgentListener {
 50
 51	public static final int LINES = 2;
 52	public int pref;
 53	
 54	public static final int UNINITIALIZED = 0x0;
 55	public static final int INITIALIZED = 0x2;
 56	
 57	/** User Agent */
 58	public UserAgent[] uas;
 59	public UserAgent ua;
 60
 61	/** Register Agent */
 62	public RegisterAgent[] ras;
 63
 64	private KeepAliveSip[] kas;
 65	
 66	/** UserAgentProfile */
 67	public UserAgentProfile[] user_profiles;
 68
 69	public SipProvider[] sip_providers;
 70	
 71	public static PowerManager.WakeLock[] wl,pwl;
 72	
 73	UserAgentProfile getUserAgentProfile(String suffix) {
 74		UserAgentProfile user_profile = new UserAgentProfile(null);
 75		
 76		user_profile.username = PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_USERNAME+suffix, Settings.DEFAULT_USERNAME); // modified
 77		user_profile.passwd = PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_PASSWORD+suffix, Settings.DEFAULT_PASSWORD);
 78		if (PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_DOMAIN+suffix, Settings.DEFAULT_DOMAIN).length() == 0) {
 79			user_profile.realm = PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_SERVER+suffix, Settings.DEFAULT_SERVER);
 80		} else {
 81			user_profile.realm = PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_DOMAIN+suffix, Settings.DEFAULT_DOMAIN);
 82		}
 83		user_profile.realm_orig = user_profile.realm;
 84		if (PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_FROMUSER+suffix, Settings.DEFAULT_FROMUSER).length() == 0) {
 85			user_profile.from_url = user_profile.username;
 86		} else {
 87			user_profile.from_url = PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_FROMUSER+suffix, Settings.DEFAULT_FROMUSER);
 88		}
 89		
 90		// MMTel configuration (added by mandrajg)
 91		user_profile.qvalue = PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_MMTEL_QVALUE, Settings.DEFAULT_MMTEL_QVALUE);
 92		user_profile.mmtel = PreferenceManager.getDefaultSharedPreferences(getUIContext()).getBoolean(Settings.PREF_MMTEL, Settings.DEFAULT_MMTEL);
 93
 94		user_profile.pub = PreferenceManager.getDefaultSharedPreferences(getUIContext()).getBoolean(Settings.PREF_EDGE+suffix, Settings.DEFAULT_EDGE) ||
 95			PreferenceManager.getDefaultSharedPreferences(getUIContext()).getBoolean(Settings.PREF_3G+suffix, Settings.DEFAULT_3G);
 96		return user_profile;
 97	}
 98
 99	public boolean StartEngine() {
100			PowerManager pm = (PowerManager) getUIContext().getSystemService(Context.POWER_SERVICE);
101			if (wl == null) {
102				if (!PreferenceManager.getDefaultSharedPreferences(getUIContext()).contains(org.sipdroid.sipua.ui.Settings.PREF_KEEPON)) {
103					Editor edit = PreferenceManager.getDefaultSharedPreferences(getUIContext()).edit();
104	
105					edit.putBoolean(org.sipdroid.sipua.ui.Settings.PREF_KEEPON, Build.MODEL.equals("Nexus One") ||
106							Build.MODEL.equals("Nexus S") ||
107							Build.MODEL.equals("Archos5") ||
108							Build.MODEL.equals("ADR6300") ||
109							Build.MODEL.equals("PC36100") ||
110							Build.MODEL.equals("HTC Desire") ||
111							Build.MODEL.equals("HTC Incredible S") ||
112							Build.MODEL.equals("HTC Wildfire") ||
113							Build.MODEL.equals("GT-I9100"));
114					edit.commit();
115				}
116				wl = new PowerManager.WakeLock[LINES];
117				pwl = new PowerManager.WakeLock[LINES];
118			}
119			pref = ChangeAccount.getPref(Receiver.mContext);
120
121			uas = new UserAgent[LINES];
122			ras = new RegisterAgent[LINES];
123			kas = new KeepAliveSip[LINES];
124			lastmsgs = new String[LINES];
125			sip_providers = new SipProvider[LINES];
126			user_profiles = new UserAgentProfile[LINES];
127			user_profiles[0] = getUserAgentProfile("");
128			for (int i = 1; i < LINES; i++)
129				user_profiles[1] = getUserAgentProfile(""+i);
130			
131			SipStack.init(null);
132			int i = 0;
133			for (UserAgentProfile user_profile : user_profiles) {
134				if (wl[i] == null) {
135					wl[i] = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Sipdroid.SipdroidEngine");
136					if (PreferenceManager.getDefaultSharedPreferences(getUIContext()).getBoolean(org.sipdroid.sipua.ui.Settings.PREF_KEEPON, org.sipdroid.sipua.ui.Settings.DEFAULT_KEEPON))
137						pwl[i] = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "Sipdroid.SipdroidEngine");
138				}
139				
140				try {
141					SipStack.debug_level = 0;
142		//			SipStack.log_path = "/data/data/org.sipdroid.sipua";
143					SipStack.max_retransmission_timeout = 4000;
144					SipStack.default_transport_protocols = new String[1];
145					SipStack.default_transport_protocols[0] = PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_PROTOCOL+(i!=0?i:""),
146							user_profile.realm.equals(Settings.DEFAULT_SERVER)?"tcp":"udp");
147					
148					String version = "Sipdroid/" + Sipdroid.getVersion() + "/" + Build.MODEL;
149					SipStack.ua_info = version;
150					SipStack.server_info = version;
151						
152					IpAddress.setLocalIpAddress();
153					sip_providers[i] = new SipProvider(IpAddress.localIpAddress, 0);
154					user_profile.contact_url = getContactURL(user_profile.username,sip_providers[i]);
155					
156					if (user_profile.from_url.indexOf("@") < 0) {
157						user_profile.from_url +=
158							"@"
159							+ user_profile.realm;
160					}
161					
162					CheckEngine();
163					
164					// added by mandrajg
165					String icsi = null;
166					if (user_profile.mmtel == true){
167						icsi = "\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"";
168					}
169		
170					uas[i] = ua = new UserAgent(sip_providers[i], user_profile);
171					ras[i] = new RegisterAgent(sip_providers[i], user_profile.from_url, // modified
172							user_profile.contact_url, user_profile.username,
173							user_profile.realm, user_profile.passwd, this, user_profile,
174							user_profile.qvalue, icsi, user_profile.pub); // added by mandrajg
175					kas[i] = new KeepAliveSip(sip_providers[i],100000);
176				} catch (Exception E) {
177				}
178				i++;
179			}
180			register();
181			listen();
182
183			return true;
184	}
185
186	private String getContactURL(String username,SipProvider sip_provider) {
187		int i = username.indexOf("@");
188		if (i != -1) {
189			// if the username already contains a @ 
190			//strip it and everthing following it
191			username = username.substring(0, i);
192		}
193
194		return username + "@" + IpAddress.localIpAddress
195		+ (sip_provider.getPort() != 0?":"+sip_provider.getPort():"")
196		+ ";transport=" + sip_provider.getDefaultTransport();		
197	}
198	
199	void setOutboundProxy(SipProvider sip_provider,int i) {
200		try {
201			if (sip_provider != null) sip_provider.setOutboundProxy(new SocketAddress(
202					IpAddress.getByName(PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_DNS+i, Settings.DEFAULT_DNS)),
203					Integer.valueOf(PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_PORT+(i!=0?i:""), Settings.DEFAULT_PORT))));
204		} catch (Exception e) {
205		}
206	}
207	
208	public void CheckEngine() {
209		int i = 0;
210		for (SipProvider sip_provider : sip_providers) {
211			if (sip_provider != null && !sip_provider.hasOutboundProxy())
212				setOutboundProxy(sip_provider,i);
213			i++;
214		}
215	}
216
217	public Context getUIContext() {
218		return Receiver.mContext;
219	}
220	
221	public int getRemoteVideo() {
222//		Logger.d("ua.remote_video_port = " + ua.remote_video_port);
223		return ua.remote_video_port;
224	}
225	
226	public int getLocalVideo() {
227//		Logger.d("ua.local_video_port = " + ua.local_video_port);
228		return ua.local_video_port;
229	}
230	
231	public String getRemoteAddr() {
232//		Logger.d("ua.remote_media_address = " + ua.remote_media_address);
233		return ua.remote_media_address;
234	}
235	
236	public void expire() {
237		Receiver.expire_time = 0;
238		int i = 0;
239		for (RegisterAgent ra : ras) {
240			if (ra != null && ra.CurrentState == RegisterAgent.REGISTERED) {
241				ra.CurrentState = RegisterAgent.UNREGISTERED;
242				Receiver.onText(Receiver.REGISTER_NOTIFICATION+i, null, 0, 0);
243			}
244			i++;
245		}
246		register();
247	}
248	
249	public void unregister(int i) {
250			if (user_profiles[i] == null || user_profiles[i].username.equals("") ||
251					user_profiles[i].realm.equals("")) return;
252
253			RegisterAgent ra = ras[i];
254			if (ra != null && ra.unregister()) {
255				Receiver.alarm(0, LoopAlarm.class);
256				Receiver.onText(Receiver.REGISTER_NOTIFICATION+i,getUIContext().getString(R.string.reg),R.drawable.sym_presence_idle,0);
257				wl[i].acquire();
258			} else
259				Receiver.onText(Receiver.REGISTER_NOTIFICATION+i, null, 0, 0);
260	}
261	
262	public void registerMore() {
263		IpAddress.setLocalIpAddress();
264		int i = 0;
265		for (RegisterAgent ra : ras) {
266			try {
267				if (user_profiles[i] == null || user_profiles[i].username.equals("") ||
268						user_profiles[i].realm.equals("")) {
269					i++;
270					continue;
271				}
272				user_profiles[i].contact_url = getContactURL(user_profiles[i].from_url,sip_providers[i]);
273		
274				if (ra != null && !ra.isRegistered() && Receiver.isFast(i) && ra.register()) {
275					Receiver.onText(Receiver.REGISTER_NOTIFICATION+i,getUIContext().getString(R.string.reg),R.drawable.sym_presence_idle,0);
276					wl[i].acquire();
277				}
278			} catch (Exception ex) {
279				
280			}
281			i++;
282		}
283	}
284	
285	public void register() {
286		IpAddress.setLocalIpAddress();
287		int i = 0;
288		for (RegisterAgent ra : ras) {
289			try {
290				if (user_profiles[i] == null || user_profiles[i].username.equals("") ||
291						user_profiles[i].realm.equals("")) {
292					i++;
293					continue;
294				}
295				user_profiles[i].contact_url = getContactURL(user_profiles[i].from_url,sip_providers[i]);
296		
297				if (!Receiver.isFast(i)) {
298					unregister(i);
299				} else {
300					if (ra != null && ra.register()) {
301						Receiver.onText(Receiver.REGISTER_NOTIFICATION+i,getUIContext().getString(R.string.reg),R.drawable.sym_presence_idle,0);
302						wl[i].acquire();
303					}
304				}
305			} catch (Exception ex) {
306				
307			}
308			i++;
309		}
310	}
311	
312	public void registerUdp() {
313		IpAddress.setLocalIpAddress();
314		int i = 0;
315		for (RegisterAgent ra : ras) {
316			try {
317				if (user_profiles[i] == null || user_profiles[i].username.equals("") ||
318						user_profiles[i].realm.equals("") ||
319						sip_providers[i] == null ||
320						sip_providers[i].getDefaultTransport() == null ||
321						sip_providers[i].getDefaultTransport().equals("tcp")) {
322					i++;
323					continue;
324				}
325				user_profiles[i].contact_url = getContactURL(user_profiles[i].from_url,sip_providers[i]);
326		
327				if (!Receiver.isFast(i)) {
328					unregister(i);
329				} else {
330					if (ra != null && ra.register()) {
331						Receiver.onText(Receiver.REGISTER_NOTIFICATION+i,getUIContext().getString(R.string.reg),R.drawable.sym_presence_idle,0);
332						wl[i].acquire();
333					}
334				}
335			} catch (Exception ex) {
336				
337			}
338			i++;
339		}
340	}
341
342	public void halt() { // modified
343		long time = SystemClock.elapsedRealtime();
344		
345		int i = 0;
346		for (RegisterAgent ra : ras) {
347			unregister(i);
348			while (ra != null && ra.CurrentState != RegisterAgent.UNREGISTERED && SystemClock.elapsedRealtime()-time < 2000)
349				try {
350					Thread.sleep(100);
351				} catch (InterruptedException e1) {
352				}
353			if (wl[i].isHeld()) {
354				wl[i].release();
355				if (pwl[i] != null && pwl[i].isHeld()) pwl[i].release();
356			}
357			if (kas[i] != null) {
358				Receiver.alarm(0, LoopAlarm.class);
359				kas[i].halt();
360			}
361			Receiver.onText(Receiver.REGISTER_NOTIFICATION+i, null, 0, 0);
362			if (ra != null)
363				ra.halt();
364			if (uas[i] != null)
365				uas[i].hangup();
366			if (sip_providers[i] != null)
367				sip_providers[i].halt();
368			i++;
369		}
370	}
371
372	public boolean isRegistered()
373	{
374		for (RegisterAgent ra : ras)
375			if (ra != null && ra.isRegistered())
376				return true;
377		return false;
378	}
379	
380	public boolean isRegistered(int i)
381	{
382		if (ras[i] == null)
383		{
384			return false;
385		}
386		return ras[i].isRegistered();
387	}
388	
389	public void onUaRegistrationSuccess(RegisterAgent reg_ra, NameAddress target,
390			NameAddress contact, String result) {
391    	int i = 0;
392    	for (RegisterAgent ra : ras) {
393    		if (ra == reg_ra) break;
394    		i++;
395    	}
396		if (isRegistered(i)) {
397			if (Receiver.on_wlan)
398				Receiver.alarm(60, LoopAlarm.class);
399			Receiver.onText(Receiver.REGISTER_NOTIFICATION+i,getUIContext().getString(i == pref?R.string.regpref:R.string.regclick),R.drawable.sym_presence_available,0);
400			reg_ra.subattempts = 0;
401			reg_ra.startMWI();
402			Receiver.registered();
403		} else
404			Receiver.onText(Receiver.REGISTER_NOTIFICATION+i, null, 0,0);
405		if (wl[i].isHeld()) {
406			wl[i].release();
407			if (pwl[i] != null && pwl[i].isHeld()) pwl[i].release();
408		}
409	}
410
411	String[] lastmsgs;
412	
413    public void onMWIUpdate(RegisterAgent mwi_ra, boolean voicemail, int number, String vmacc) {
414    	int i = 0;
415    	for (RegisterAgent ra : ras) {
416    		if (ra == mwi_ra) break;
417    		i++;
418    	}
419    	if (i != pref) return;
420		if (voicemail) {
421			String msgs = getUIContext().getString(R.string.voicemail);
422			if (number != 0) {
423				msgs = msgs + ": " + number;
424			}
425			Receiver.MWI_account = vmacc;
426			if (lastmsgs[i] == null || !msgs.equals(lastmsgs[i])) {
427				Receiver.onText(Receiver.MWI_NOTIFICATION, msgs,android.R.drawable.stat_notify_voicemail,0);
428				lastmsgs[i] = msgs;
429			}
430		} else {
431			Receiver.onText(Receiver.MWI_NOTIFICATION, null, 0,0);
432			lastmsgs[i] = null;
433		}
434	}
435
436	static long lasthalt,lastpwl;
437	
438	/** When a UA failed on (un)registering. */
439	public void onUaRegistrationFailure(RegisterAgent reg_ra, NameAddress target,
440			NameAddress contact, String result) {
441		boolean retry = false;
442    	int i = 0;
443    	for (RegisterAgent ra : ras) {
444    		if (ra == reg_ra) break;
445    		i++;
446    	}
447    	if (isRegistered(i)) {
448    		reg_ra.CurrentState = RegisterAgent.UNREGISTERED;
449    		Receiver.onText(Receiver.REGISTER_NOTIFICATION+i, null, 0, 0);
450    	} else {
451    		retry = true;
452    		Receiver.onText(Receiver.REGISTER_NOTIFICATION+i,getUIContext().getString(R.string.regfailed)+" ("+result+")",R.drawable.sym_presence_away,0);
453    	}
454    	if (retry && SystemClock.uptimeMillis() > lastpwl + 45000 && pwl[i] != null && !pwl[i].isHeld() && Receiver.on_wlan) {
455			lastpwl = SystemClock.uptimeMillis();
456			if (wl[i].isHeld())
457				wl[i].release();
458			pwl[i].acquire();
459			register();
460			if (!wl[i].isHeld() && pwl[i].isHeld()) pwl[i].release();
461		} else if (wl[i].isHeld()) {
462			wl[i].release();
463			if (pwl[i] != null && pwl[i].isHeld()) pwl[i].release();
464		}
465		if (SystemClock.uptimeMillis() > lasthalt + 45000) {
466			lasthalt = SystemClock.uptimeMillis();
467			sip_providers[i].haltConnections();
468		}
469		if (!Thread.currentThread().getName().equals("main"))
470			updateDNS();
471		reg_ra.stopMWI();
472    	WifiManager wm = (WifiManager) Receiver.mContext.getSystemService(Context.WIFI_SERVICE);
473    	wm.startScan();
474	}
475	
476	public void updateDNS() {
477		Editor edit = PreferenceManager.getDefaultSharedPreferences(getUIContext()).edit();
478		int i = 0;
479		for (SipProvider sip_provider : sip_providers) {
480			try {
481				edit.putString(Settings.PREF_DNS+i, IpAddress.getByName(PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_SERVER+(i!=0?i:""), "")).toString());
482			} catch (UnknownHostException e1) {
483				i++;
484				continue;
485			}
486			edit.commit();
487			setOutboundProxy(sip_provider,i);
488			i++;
489		}
490	}
491
492	/** Receives incoming calls (auto accept) */
493	public void listen() 
494	{
495		for (UserAgent ua : uas) {
496			if (ua != null) {
497				ua.printLog("UAS: WAITING FOR INCOMING CALL");
498				
499				if (!ua.user_profile.audio && !ua.user_profile.video)
500				{
501					ua.printLog("ONLY SIGNALING, NO MEDIA");
502				}
503				
504				ua.listen();
505			}
506		}
507	}
508	
509	public void info(char c, int duration) {
510		ua.info(c, duration);
511	}
512	
513	/** Makes a new call */
514	public boolean call(String target_url,boolean force) {
515		int p = pref;
516		boolean found = false;
517		
518		if (isRegistered(p) && Receiver.isFast(p))
519			found = true;
520		else {
521			for (p = 0; p < LINES; p++)
522				if (isRegistered(p) && Receiver.isFast(p)) {
523					found = true;
524					break;
525				}
526			if (!found && force) {
527				p = pref;
528				if (Receiver.isFast(p))
529					found = true;
530				else for (p = 0; p < LINES; p++)
531					if (Receiver.isFast(p)) {
532						found = true;
533						break;
534					}
535			}
536		}
537				
538		if (!found || (ua = uas[p]) == null) {
539			if (PreferenceManager.getDefaultSharedPreferences(getUIContext()).getBoolean(Settings.PREF_CALLBACK, Settings.DEFAULT_CALLBACK) &&
540					PreferenceManager.getDefaultSharedPreferences(getUIContext()).getString(Settings.PREF_POSURL, Settings.DEFAULT_POSURL).length() > 0) {
541				Receiver.url("n="+Uri.decode(target_url));
542				return true;
543			}
544			return false;
545		}
546
547		ua.printLog("UAC: CALLING " + target_url);
548		
549		if (!ua.user_profile.audio && !ua.user_profile.video)
550		{
551			 ua.printLog("ONLY SIGNALING, NO MEDIA");
552		}
553		return ua.call(target_url, false);
554	}
555
556	public void answercall() 
557	{
558		Receiver.stopRingtone();
559		ua.accept();
560	}
561
562	public void rejectcall() {
563		ua.printLog("UA: HANGUP");
564		ua.hangup();
565	}
566
567	public void togglehold() {
568		ua.reInvite(null, 0);
569	}
570
571	public void transfer(String number) {
572		ua.callTransfer(number, 0);
573	}
574	
575	public void togglemute() {
576		if (ua.muteMediaApplication())
577			Receiver.onText(Receiver.CALL_NOTIFICATION, getUIContext().getString(R.string.menu_mute), android.R.drawable.stat_notify_call_mute,Receiver.ccCall.base);
578		else
579			Receiver.progress();
580	}
581	
582	public void togglebluetooth() {
583		ua.bluetoothMediaApplication();
584		Receiver.progress();
585	}
586	
587	public int speaker(int mode) {
588		int ret = ua.speakerMediaApplication(mode);
589		Receiver.progress();
590		return ret;
591	}
592	
593	public void keepAlive() {
594		int i = 0;
595		for (KeepAliveSip ka : kas) {
596			if (ka != null && Receiver.on_wlan && isRegistered(i))
597				try {
598					ka.sendToken();
599					Receiver.alarm(60, LoopAlarm.class);
600				} catch (IOException e) {
601					if (!Sipdroid.release) e.printStackTrace();
602				}
603			i++;
604		}
605	}
606}