Exemplo n.º 1
0
 public StatusChangedEventArgs(ConnMgr.ConnectionStatus connstatus, string desc)
 {
     this.connstatus = connstatus;
     this.desc = desc;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Returns the Status Description for the current GPRS connection
 /// </summary>
 public string GetStatusDesc(ConnMgr.ConnectionStatus connstatus)
 {
     ConnMgr.ConnectionStatus connectionStatu = connstatus;
     if (connectionStatu > ConnMgr.ConnectionStatus.Suspended)
     {
         switch (connectionStatu)
         {
             case ConnMgr.ConnectionStatus.Disconnected:
                 {
                     return "Disconnected";
                 }
             case ConnMgr.ConnectionStatus.ConnectionFailed:
                 {
                     return "Connection failed";
                 }
             case ConnMgr.ConnectionStatus.ConnectionCanceled:
                 {
                     return "User cancelled";
                 }
             case ConnMgr.ConnectionStatus.ConnectionDisabled:
                 {
                     return "The connection can be made, but the connection itself is disabled";
                 }
             case ConnMgr.ConnectionStatus.NoPathToDestination:
                 {
                     return "No path to the destination could be found";
                 }
             case ConnMgr.ConnectionStatus.WaitingForPath:
                 {
                     return "A path to the destination exists but is not presently available";
                 }
             case ConnMgr.ConnectionStatus.WaitingForPhone:
                 {
                     return "A voice call is in progress and is using resources that this connection requires";
                 }
             case ConnMgr.ConnectionStatus.PhoneOff:
                 {
                     return "The phone has been turned off";
                 }
             case ConnMgr.ConnectionStatus.ExclusiveConflict:
                 {
                     return "The connection could not be established because it would multi-home an exclusive connection";
                 }
             case ConnMgr.ConnectionStatus.NoResources:
                 {
                     return "The Connection Manager failed to allocate resources to make the connection";
                 }
             case ConnMgr.ConnectionStatus.ConnectionLinkedFailed:
                 {
                     return "The connection link was prematurely disconnected";
                 }
             case ConnMgr.ConnectionStatus.AuthenticationFailed:
                 {
                     return "The user could not be authenticated";
                 }
             default:
                 {
                     switch (connectionStatu)
                     {
                         case ConnMgr.ConnectionStatus.WaitingConnection:
                             {
                                 return "The device is attempting to connect";
                             }
                         case ConnMgr.ConnectionStatus.WaitingForResource:
                             {
                                 return "Another client is using resources that this connection requires";
                             }
                         case ConnMgr.ConnectionStatus.WaitingForNetwork:
                             {
                                 return "The device is waiting for a task with a higher priority to connect to the network before connecting to the same network. This status value is returned only to clients that specify a priority of CONNMGR_PRIORITY_LOWBKGND when requesting a connection";
                             }
                         default:
                             {
                                 switch (connectionStatu)
                                 {
                                     case ConnMgr.ConnectionStatus.WaitingDisconnection:
                                         {
                                             return "The connection is being brought down";
                                         }
                                     case ConnMgr.ConnectionStatus.WaitingConnectionAbort:
                                         {
                                             return "The device is aborting the connection attempt";
                                         }
                                 }
                                 break;
                             }
                     }
                     break;
                 }
         }
     }
     else
     {
         if (connectionStatu == ConnMgr.ConnectionStatus.Unknown)
         {
             return "Unknown status";
         }
         switch (connectionStatu)
         {
             case ConnMgr.ConnectionStatus.Connected:
                 {
                     return "Connected";
                 }
             case ConnMgr.ConnectionStatus.Suspended:
                 {
                     return "The connection has been established, but has been suspended";
                 }
         }
     }
     return "Unknown status";
 }
Exemplo n.º 3
0
 /// <summary>
 /// Attempts to create and establish a connection to a new GPRS connectoid using the specified ISP parameters
 /// </summary>
 /// <param name="EntryName">Name to be given to the new GPRS connectoid</param>
 /// <param name="mode">ConnectionMode is either Synchronous or Asynchronous</param>
 /// <param name="Username">User name provided by local ISP</param>
 /// <param name="Password">Password provided by local ISP</param>
 /// <param name="APN">Access Point Name provided by local ISP</param>
 public void Connect(string EntryName, ConnMgr.ConnectionMode mode, string Username, string Password, string APN)
 {
     if (EntryName == null || EntryName == "")
     {
         throw new ArgumentException("EntryName is invalid");
     }
     if (Username == null)
     {
         throw new ArgumentException("Username is invalid");
     }
     if (Password == null)
     {
         throw new ArgumentException("Password is invalid");
     }
     if (APN == null)
     {
         throw new ArgumentException("APN is invalid");
     }
     int num = 0;
     Guid guid = new Guid("ADB0B001-10B5-3F39-27C6-9742E785FCD4");
     IntPtr zero = IntPtr.Zero;
     object[] entryName = new object[] { "<wap-provisioningdoc><characteristic type=\"CM_GPRSEntries\"><characteristic type=\"", EntryName, "\"><parm name=\"DestId\" value=\"{", guid, "}\"/><parm name=\"Phone\" value=\"~GPRS!", APN, "\"/><parm name=\"UserName\" value=\"", Username, "\"/><parm name=\"Password\" value=\"", Password, "\"/><parm name=\"DeviceType\" value=\"modem\"/><parm name=\"DeviceName\" value=\"Cellular Line\"/><parm name=\"Enabled\" value=\"1\"/><parm name=\"RequirePw\" value=\"1\"/><characteristic type=\"DevSpecificCellular\"><parm name=\"GPRSInfoAccessPointName\" value=\"", APN, "\"/></characteristic></characteristic></characteristic></wap-provisioningdoc>" };
     string str = string.Concat(entryName);
     num = ConnMgr.sysDMProcessConfigXML(str, 1, out zero);
     if (num != 0)
     {
         ConnMgr.sysOperator_Delete(zero);
         throw new ExternalException("DMProcessConfigXML failed", Marshal.GetExceptionForHR(num));
     }
     if (zero == IntPtr.Zero)
     {
         throw new Exception("xmlOut did not get set");
     }
     string stringUni = Marshal.PtrToStringUni(zero);
     ConnMgr.sysOperator_Delete(zero);
     if (stringUni.IndexOf("parm-error") > -1)
     {
         string[] strArrays = new string[] { "Can't set username and password for ", EntryName, " [", num.ToString(), "]" };
         throw new Exception(string.Concat(strArrays));
     }
     num = ConnMgr.sysConnMgrMapConRef(0, EntryName, out guid);
     if (num != 0)
     {
         string[] entryName1 = new string[] { "Can't map connection reference for ", EntryName, " [", num.ToString(), "]" };
         throw new ExternalException(string.Concat(entryName1), Marshal.GetExceptionForHR(num));
     }
     this.Connect(guid, false, mode);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Attempts to create and establish a connection to a new GPRS connectoid using the specified XML string
 /// </summary>
 /// <param name="EntryName">Name to be given to the new GPRS connectoid</param>
 /// <param name="mode">ConnectionMode is either Synchronous or Asynchronous</param>
 /// <param name="xmlIn">Complete XML string used to create new connectoid (refer to Connection Manager)</param>
 public void Connect(string EntryName, ConnMgr.ConnectionMode mode, string xmlIn)
 {
     Guid guid;
     if (xmlIn == null || xmlIn == "")
     {
         throw new ArgumentException("xmlIn is invalid");
     }
     IntPtr zero = IntPtr.Zero;
     int num = ConnMgr.sysDMProcessConfigXML(xmlIn, 1, out zero);
     if (num != 0)
     {
         ConnMgr.sysOperator_Delete(zero);
         throw new ExternalException("DMProcessConfigXML failed", Marshal.GetExceptionForHR(num));
     }
     if (zero == IntPtr.Zero)
     {
         throw new Exception("xmlOut did not get set");
     }
     string stringUni = Marshal.PtrToStringUni(zero);
     ConnMgr.sysOperator_Delete(zero);
     if (stringUni.IndexOf("parm-error") > -1)
     {
         string[] entryName = new string[] { "Can't set username and password for ", EntryName, " [", num.ToString(), "]" };
         throw new Exception(string.Concat(entryName));
     }
     num = ConnMgr.sysConnMgrMapConRef(0, EntryName, out guid);
     if (num != 0)
     {
         string[] strArrays = new string[] { "Can't map connection reference for ", EntryName, " [", num.ToString(), "]" };
         throw new ExternalException(string.Concat(strArrays), Marshal.GetExceptionForHR(num));
     }
     this.Connect(guid, false, mode);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Attempts to establish a connection using the GUID to an existing connectoid
 /// </summary>
 /// <param name="destGuid">GUID of existing connectoid</param>
 /// <param name="exclusive">Exclusive access of connectoid (boolean)</param>
 /// <param name="mode">ConnectionMode is either Synchronous or Asynchronous</param>
 public void Connect(Guid destGuid, bool exclusive, ConnMgr.ConnectionMode mode)
 {
     ConnMgr.ConnectionInfo connectionInfo = new ConnMgr.ConnectionInfo();
     connectionInfo.dwParams = 1;
     connectionInfo.dwPriority = 8192;
     connectionInfo.dwFlags = 65;
     connectionInfo.bExclusive = exclusive;
     connectionInfo.bDisabled = false;
     connectionInfo.guidDestNet = destGuid;
     connectionInfo.hWnd = this.connMgrWindow.Hwnd;
     connectionInfo.uMsg = 51917;
     connectionInfo.lParam = 0;
     connectionInfo.MarshalToUnManaged();
     int num = 0;
     if (mode != ConnMgr.ConnectionMode.Synchronous)
     {
         ConnMgr.sysConnMgrEstablishConnection(connectionInfo.structPtr, out this.hConnMgr);
     }
     else
     {
         int num1 = ConnMgr.sysConnMgrEstablishConnectionSync(connectionInfo.structPtr, out this.hConnMgr, this.Timeout, out num);
         if (num1 != 0)
         {
             throw new ExternalException("ConnMgrEstablishConnectionSync failed", Marshal.GetExceptionForHR(num1));
         }
     }
 }