Call Forwarding Windows Mobile Using OpenNetCF

May 17, 2010 at 11:11 AM

Hi,

I am working on a project for which i need call forwarding. So, for this i have used OpenNetCF Libraries.

But in this library i am not able to find any class or method for doing so.

I tried to do CallForwarding as below.But i always get an exception.

string dial = "**21*XYZ#";
            // Initialize TAPI
            Telephony phone = new Telephony();
            phone.Initialize();

            // Get a reference to the cellular line from the phone stack
            Line line = phone.CellularLine(MediaMode.

InteractiveVoice, CallPrivilege.None);
                        
            // Query the address status of the cellular line
            AddressStatus status = new AddressStatus(2048);
            status.Store();
            NativeMethods.lineGetAddressStatus(line.hLine, 0, status.Data);
            status.Load();


            if (status.ForwardSize > 0)
            {
                // Create a new forwarding list and populate with forwards that are already configured
                lfl = new ForwardList(status.ForwardSize);
                Buffer.BlockCopy(status.Data, status.ForwardOffset, lfl.Data, 0, status.ForwardSize);
                MessageBox.Show("populated forwardlist");

                // Display information about each forward
                lfl.NumEntries = status.ForwardNumEntries;
                for (int i = 0; i < lfl.NumEntries; i++)
                {
                    LineForward lf = lfl.List[i];
                    MessageBox.Show("loaded forward " + i.ToString());
                    string number = Encoding.Unicode.GetString(status.Data, lf.DestAddressOffset, lf.DestAddressSize);
                    MessageBox.Show(string.Format("Forward mode: {0}, number: {1}", lf.ForwardMode, number));
                }
            }

            int nEntries = 1;
            int nTextLen = 0;

            for (int nNumber = 0; nNumber < nEntries; ++nNumber)
            {
                nTextLen += (((dial.Length) + 1) * sizeof(char));
            }

            int dwSize = nTextLen;
            dwSize += (Marshal.SizeOf(typeof(LineForward)));

            int dwOffset = (Marshal.SizeOf(typeof(LineForward)));

            ForwardList pList = new ForwardList(dwSize);
            pList.NumEntries = nEntries;
            IntPtr lphConsultCall = IntPtr.Zero;
            for (int nNumber = 0; nNumber < nEntries; nNumber++)
            {
                pList.List[nNumber].ForwardMode = ForwardMode.Unconditional;
                pList.List[nNumber].CallerAddressSize = 1;
                pList.List[nNumber].CallerAddressOffset = 0;
                pList.List[nNumber].DestCountryCode = 0;
                pList.List[nNumber].DestAddressSize = dwSize;
                pList.List[nNumber].DestAddressOffset = dwOffset;
            }

            int result = NativeMethods.lineForward(line.hLine, 0, 0, pList, 0, ref lphConsultCall, null);
            if (result != 0)
            {
                throw new ApplicationException(string.Format("lineNegotiateAPIVersion failed!\n\nError Code: {0}", result.ToString()));
            }

            // Cleanup any TAPI references
            status.Store();
            line.Dispose();
            phone.Shutdown();

But i am getting an exception. May be due to not proper way to set size.

Any one who have any idea please help me.


Thanks in advance.


Rahul Jaiswal
May 18, 2010 at 11:19 AM

Anybody having any idea please help.

Its urgent for me.

Help me.

Waiting for the reply

Oct 8, 2011 at 2:09 PM

Hi,

Did you ever manage to find a solution for this?