/// <summary>
        /// Processes a message in the queue
        /// </summary>
        /// <param name="obj"></param>
        private void ProcessMessage(MessageObject obj)
        {
            try
            {

                if(obj != null)
                {

                    WebMeeting.Common.DocumentSharing DocSharing = (WebMeeting.Common.DocumentSharing)obj;

                    DocumentSharingEx DocEx = new WebMeeting.Client.DocumentSharingEx(DocSharing.DocumentType,DocSharing.sessionID);
                    DocEx.OnStatusUpdateFunction = new WebMeeting.Client.DocumentSharingEx.OnStatusUpdate(OnStatusUpdate);

                    string localFilePath = this.DocumentFilePath;
                    SetControls(false);

            /////////////     ===============================================================//////////
            ///                                      By Zaeem uncomented
            /////////////     ===============================================================//////////

            /*
                    // used for downloading documents.

                    if(!m_DocumentDownloaded) // these checks are for ppt and xls sharing cause there can be Next and Previous movement messages
                    { // keep track if the presentation has already been downloaded don't download it again. just move the the current page of presentation
                        if(!DocEx.RecieveDocumentSharing(obj,out localFilePath)) //Failed
                        {
                            this.MessagePool.Remove(obj);

                            //						alert.ShowMessage(4,"Unable to download document to webserver","WebMeeting",MessageBoxButtons.OK,MessageBoxIcon.Error);
                            //Process failure

                            return;
                        }
                        else
                            this.m_DocumentDownloaded = true;

                        this.DocumentFilePath = localFilePath;

                        annotationBrowser.sheetsEventStores = new ArrayList();
                        annotationBrowser.sheetsEventStores.Add(annotationBrowser.eventStore);
                        // only for checking purpose
                        try
                        {
                            for(int i = 1 ;i < DocSharing.TotalPages ; i++) //Create Transparent Annotation windows over the
                                //browser control for drawing on each presentation page.
                            {
                                annotationBrowser.eventStore = new ArrayList();
                                annotationBrowser.sheetsEventStores.Add(annotationBrowser.eventStore );
                            }
                        }
                        catch(Exception ee)
                        {
                            annotationBrowser.eventStore = new ArrayList();
                            annotationBrowser.sheetsEventStores.Add(annotationBrowser.eventStore );
                            ee = ee;
                        }

                        this.documentTitle = Path.GetFileNameWithoutExtension(DocumentFilePath);
                        AddSaveMenus();

                    }
            */

            /////////////     ===============================================================//////////
            ///                                      End Block
            /////////////     ===============================================================//////////

                    /////////////

                    this.DocumentFilePath = localFilePath;
                    this.pictureCount = DocSharing.TotalPages;
                    //synchornizePPTAnnotations();
                    m_DocumentMessage = DocSharing;

                    switch(m_DocumentMessage.DocumentType)
                    {
                        case DocumentMessageType.typeDocument:
                        {//Load the Word Document
                            object oUrl = m_DocumentMessage.DownloadURL;
                            object o = new object();
                            if(!m_bVisited)
                            {
                                this.axWebBrowser1.Navigate2(ref oUrl,ref o,ref o,ref o,ref o);
                                lblStatus.Text ="Document " + Path.GetFileName(this.DocumentFilePath);
                                m_bVisited = true;
                            }

                        }
                            break;
                        case DocumentMessageType.typePresentation:
                        {
            //							this.DocumentFilePath = localFilePath;
            //							localFilePath = Directory.GetParent(localFilePath).FullName;
                            //object oUrl = localFilePath + "\\slide" +
                            object oUrl = m_DocumentMessage.DownloadURL+DocSharing.CurrentPage.ToString() + ".jpg";
                            object o = new object();

                            if(currentImage != m_DocumentMessage.CurrentPage)
                            {
                                if(File.Exists(strLocalPath+"\\"+DocSharing.CurrentPage.ToString() + ".jpg"))
                                {
                                    oUrl=strLocalPath+"\\"+DocSharing.CurrentPage.ToString() + ".jpg";
                                    this.axWebBrowser1.Navigate2(ref oUrl,ref o,ref o,ref o,ref o);
                                }
                                else
                                    this.axWebBrowser1.Navigate2(ref oUrl,ref o,ref o,ref o,ref o);
                            }

                            currentImage = m_DocumentMessage.CurrentPage;
                            pictureCount = m_DocumentMessage.TotalPages;
                            /////////////////////////////////////////

                            annotationBrowser.currentSlideNo=currentImage ;
                            /////////////////////////////////////////
                            lblStatus.Text = "Slide " + currentImage.ToString() + " of " + pictureCount.ToString();

                        }break;
                        case DocumentMessageType.typePDF:
                        {
                            //object oUrl = Path.GetDirectoryName(localFilePath) + "\\"+  Path.GetFileNameWithoutExtension(localFilePath) + "\\index.htm";
                            object oUrl=this.m_DocumentMessage.DownloadURL;
                            object o = new object();
                            if(!m_bVisited)
                            {
                                this.axWebBrowser1.Navigate2(ref oUrl,ref o,ref o,ref o,ref o);
                                m_bVisited = true;
                            }
                        }
                            break;
                        case DocumentMessageType.typeExcel:
                        {
                            object oUrl = m_DocumentMessage.DownloadURL;
                            object o = new object();
                            if((this.pictureCount == 1) || (m_DocumentMessage.TotalPages == 1))
                            {
                                lblStatus.Text = "Book 1 of 1";
                                this.axWebBrowser1.Navigate2(ref oUrl,ref o,ref o,ref o,ref o);
                            }
                            else
                            {

                                string basePath = m_DocumentMessage.DownloadURL;
                                //string basePath = Path.GetDirectoryName(localFilePath);
                                //basePath +=  "\\" + Path.GetFileNameWithoutExtension(localFilePath) + "_files\\sheet";
                                //currentImage+=1;
                                if(this.m_DocumentMessage.CurrentPage > 10)
                                    basePath += this.m_DocumentMessage.CurrentPage.ToString() + ".htm";
                                else
                                    basePath += "00" +  this.m_DocumentMessage.CurrentPage.ToString() + ".htm";
                                //MessageBox.Show(basePath);

                                oUrl = basePath;
                                if(!m_bVisited)
                                {
                                    this.axWebBrowser1.Navigate2(ref oUrl,ref o,ref o,ref o,ref o);
                                    lblStatus.Text = "Book " + currentImage.ToString() + " of " + pictureCount.ToString();
                                    if(this.m_DocumentMessage.TotalPages==1)
                                        m_bVisited =true;

                                }

                            }

                        }
                            break;
                    }
                    SetControls(true);
                    lblStatus.Visible = false;

                    if(m_bOwnerofthisControl)
                    {
                        btnOptions.Visible = true;
                        btnOptions.Enabled = true;
                        btnOptions.Top = btnLast.Top+4;
                        //chkSynch.Visible = true;
                    }
                    else
                    {
                        btnOptions.Visible = false;

                    }
                    chkThumbNail.Enabled =  m_bIsAllowedToAddAnnotations;

                    if(this.documentType == DocumentMessageType.typePresentation && chkThumbnail==false)
                    {
                        try
                        {
                            if(ClientUI.getInstance().IsShowThumbnails())/*check either we need to display thumnails or not*/
                            {
                                createThumbnailThread = new Thread(new ThreadStart(CreateThumbnails));
                                createThumbnailThread.Name = "createThumbnailThread() : documentSharingControl";
                                createThumbnailThread.Start();
                            }
                        }
                        catch(Exception ex)
                        {
                            ex = ex;
                        }
                        //CreateThumbnails();

                        chkThumbnail=true;
                        this.panelAnnotations.Height=65;
                    }

                }
            }
            catch (WebException exp)
            {
                WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("documentSharingControl.cs ==>ProcessMessage( line==> 2265",exp,null,false);
                //MeetingAlerts alert=new MeetingAlerts();
                //alert.ShowMessage(Alerts.MeetingAlerts.AlertType.NonFatal,this.Name + " Class : ProcessMessage() function ," + ex.Source + " Source ," + ex.Message  ,true,false);
            }
        }
        private void DocumentSharingThread()
        {
            //string strExt=".ppt";
            int no_of_RemoteFiles=8;
            string strPostRemoteUrl="";
            bool isRemoteUrlExist=false;
            string recordid="";
            MessageObject objMsg ;
            FileInfo theinfo;

            try
            {
                if(!this.IsLaunchFromMangeContent)
                {//in case false-----check manage content slideshow
                    //run when document is shared using menus.
                    //string Extension =strExt;//Path.GetExtension(DocumentFilePath);
                    string filename=Path.GetFileName(DocumentFilePath);
                    filenamed=Path.GetFileNameWithoutExtension(DocumentFilePath);
                    DocumentFilePath_temp=DocumentFilePath;
                    string Extension =Path.GetExtension(DocumentFilePath_temp);

                    theFile=new FileInfo(filename);

                    // 10 Mb Check
                    if((theFile.Length/1048576)>10)
                    {
                        MeetingAlerts alert=new MeetingAlerts();
                        alert.ShowMessage(Alerts.MeetingAlerts.AlertType.Info,"The size of this file is greater then 10Mb which may take time to Upload ",true,false);

                    }
                    //filenamed+=theFile.LastAccessTime.ToFileTime().ToString();

                    filenamed+=theFile.LastWriteTime.ToFileTime().ToString();
                    filenamed=filenamed.Replace('.','z');
                    filenamed=filenamed+Extension;
                    theFile.CopyTo(filenamed,true);
                    DocumentFilePath=Path.GetDirectoryName(DocumentFilePath)+@"\"+filenamed;
                    //DocumentFilePath=Path.GetFullPath(DocumentFilePath)+@"\"+filenamed;
                    Extension =Path.GetExtension(DocumentFilePath_temp);
                    //DocumentFilePath+=Extension
                    Extension = Extension.ToLower();

                    if(Extension == ".doc" ||Extension == ".docx")
                    {
                        documentType = DocumentMessageType.typeDocument;
                        strPostRemoteUrl="/"+Path.GetFileNameWithoutExtension(DocumentFilePath)+".htm";
                    }
                    else if(Extension == ".xls" ||Extension == ".xlsx")
                    {
                        documentType = DocumentMessageType.typeExcel;
                        if(no_of_RemoteFiles==1)
                            strPostRemoteUrl="/"+Path.GetFileNameWithoutExtension(DocumentFilePath)+".htm";
                        else
                            strPostRemoteUrl="/"+Path.GetFileNameWithoutExtension(DocumentFilePath)+"_files/sheet";
                    }
                    else if(Extension == ".ppt" || Extension == ".pptx")
                    {
                        documentType = DocumentMessageType.typePresentation;
                        // German PPT
                        //strPostRemoteUrl="/Folie";
                        strPostRemoteUrl="/slide";
                    }
                    else if(Extension == ".pdf")
                    {
                        documentType = DocumentMessageType.typePDF;
                        strPostRemoteUrl="/index.htm";
                    }

                    theinfo=new FileInfo(this.DocumentFilePath);
                    recordid=Client.ClientUI.getInstance().findRecord(Path.GetFileName(this.DocumentFilePath),theinfo.LastWriteTime.ToShortDateString().ToString());
                    if(recordid!="-1")
                        isRemoteUrlExist=true;
                    else
                    {
                        strLocalPath="";
                        isRemoteUrlExist=false;
                    }

                    //         Zaeem
                    if(isRemoteUrlExist==false)
                    {
                        DocumentSharingEx docEx = new WebMeeting.Client.DocumentSharingEx(
                            documentType,this.sessionID,Info.getInstance().FtpIP,Info.getInstance().UserName,
                            Info.getInstance().Password,Info.getInstance().ConferenceID);

                        docEx.OnStatusUpdateFunction = new WebMeeting.Client.DocumentSharingEx.OnStatusUpdate(OnStatusUpdate);
                        //MessageObject objMsg ;

                        //			docEx.DocumentShareStart(DocumentFilePath,out objMsg);

                        if(!docEx.DocumentShareStart(DocumentFilePath,out objMsg))
                        {
                            //Handle the failure;
                            MeetingAlerts alert=new MeetingAlerts();
                            alert.ShowMessage(Alerts.MeetingAlerts.AlertType.Info,"Unable to upload document to webserver",true,false);
                            return;
                        }
                        //						if(WebMeeting.Client.ClientUI.getInstance().InsertNewRecord(filename,((DocumentSharing)objMsg).DownloadURL,this.DocumentFilePath,((DocumentSharing)objMsg).TotalPages,((DocumentSharing)objMsg).DocumentType.ToString(),this.sessionID))
                        //							MessageBox.Show("Record Inserted");
                        //						else
                        //							MessageBox.Show("Record Not Inserted");
                        //
                        if(Extension == ".doc" ||Extension == ".docx")
                        {
                            documentType = DocumentMessageType.typeDocument;
                            strPostRemoteUrl="/"+Path.GetFileNameWithoutExtension(DocumentFilePath)+".htm";
                        }
                        else if(Extension == ".xls" || Extension == ".xlsx")
                        {
                            documentType = DocumentMessageType.typeExcel;

                            if(((DocumentSharing)objMsg).TotalPages==1)
                                //if()
                                strPostRemoteUrl="/"+Path.GetFileNameWithoutExtension(DocumentFilePath)+".htm";
                            else
                                strPostRemoteUrl="/"+Path.GetFileNameWithoutExtension(DocumentFilePath)+"_files/sheet";
                        }
                        else if(Extension == ".ppt" || Extension == ".pptx")
                        {
                            documentType = DocumentMessageType.typePresentation;
                            // German PPT
                            //strPostRemoteUrl="/Folie";
                            strPostRemoteUrl="/slide";
                        }
                        else if(Extension == ".pdf")
                        {
                            documentType = DocumentMessageType.typePDF;
                            strPostRemoteUrl="/index.htm";
                        }

                        IntializationCompleted = true;
                        //((DocumentSharing)objMsg).TotalPages=no_of_RemoteFiles;

                        ((DocumentSharing)objMsg).DownloadURL+=strPostRemoteUrl;
                        //MessageBox.Show("==>((DocumentSharing)objMsg).DownloadURL"+((DocumentSharing)objMsg).DownloadURL);
                        this.pictureCount = ((DocumentSharing)objMsg).TotalPages;
                        //theinfo=new FileInfo(this.DocumentFilePath);
                        Client.ClientUI.getInstance().InsertNewRecord(Path.GetFileName(DocumentFilePath),((DocumentSharing)objMsg).DownloadURL, Application.StartupPath +"\\" + this.sessionID.ToString()  ,((DocumentSharing)objMsg).TotalPages,((DocumentSharing)objMsg).DocumentType.ToString(),this.sessionID,theinfo.LastWriteTime.ToShortDateString().ToString());
                        theinfo=null;
                    }
                        ////////////               BY Zaeem                     ///////
                    else
                    {
                        DocumentSharing msg=new DocumentSharing();
                        objMsg=msg;
                        DataRow drShareMessage;
                        drShareMessage=Client.ClientUI.getInstance().getRecord(Convert.ToInt32(recordid));
                        string Extsion =Path.GetExtension(drShareMessage["FileName"].ToString());
                        this.strLocalPath=drShareMessage["LocalPath"].ToString();
                        if(Extsion == ".doc" ||Extsion == ".docx")
                        {
                            ((DocumentSharing)objMsg).DocumentType= DocumentMessageType.typeDocument;
                            //strPostRemoteUrl="/"+Path.GetFileNameWithoutExtension(DocumentFilePath)+".htm";
                        }
                        else if(Extsion == ".xls" || Extsion == ".xlsx")
                        {
                            ((DocumentSharing)objMsg).DocumentType= DocumentMessageType.typeExcel;
                            //							if(no_of_RemoteFiles==1)
                            //								strPostRemoteUrl="/"+Path.GetFileNameWithoutExtension(DocumentFilePath)+".htm";
                            //							else
                            //								strPostRemoteUrl="/"+Path.GetFileNameWithoutExtension(DocumentFilePath)+"_files/sheet";
                        }
                        else if(Extsion == ".ppt" || Extsion == ".pptx")
                        {
                            ((DocumentSharing)objMsg).DocumentType= DocumentMessageType.typePresentation;
                            //	strPostRemoteUrl="/slide";
                        }
                        else if(Extsion == ".pdf")
                        {
                            ((DocumentSharing)objMsg).DocumentType= DocumentMessageType.typePDF;
                            //	strPostRemoteUrl="/index.htm";
                        }
                        this.documentType=((DocumentSharing)objMsg).DocumentType;
                        //drShareMessage["LocalPath"]
                        ((DocumentSharing)objMsg).SenderID= NetworkManager.getInstance().profile.ClientId;
                        ((DocumentSharing)objMsg).ConferenceID=NetworkManager.getInstance().profile.ConferenceID;
                        ((DocumentSharing)objMsg).senderProfile=NetworkManager.getInstance().profile;
                        //((DocumentSharing)objMsg).ConferenceID=Info.getInstance().ConferenceID;
                        ((DocumentSharing)objMsg).sessionID=Convert.ToInt32(drShareMessage["Session"].ToString());
                        ((DocumentSharing)objMsg).DocumentSharingSessionId=Convert.ToInt32(drShareMessage["Session"].ToString());
                        ((DocumentSharing)objMsg).CurrentPage=1;
                        //						((DocumentSharing)objMsg).MessageType=
                        ((DocumentSharing)objMsg).nScrollX=0;
                        ((DocumentSharing)objMsg).nScrollY=0;
                        this.sessionID=	Convert.ToInt32(drShareMessage["Session"].ToString());
                        IntializationCompleted = true;
                        //drShareMessage["Session"]
                        ((DocumentSharing)objMsg).TotalPages=Convert.ToInt32(drShareMessage["TotalPages"]);
                        ((DocumentSharing)objMsg).DownloadURL=drShareMessage["RemoteURL"].ToString();

                        this.pictureCount = ((DocumentSharing)objMsg).TotalPages;
                        drShareMessage=null;
                    }

                    ProcessMessage(objMsg); //TODO:: optimized way is to add this mssg to poll and let thread do it
                    //but this causses file sharing error while same machine testing

                    //MessagePool.Add(objMsg);
                    NetworkManager.getInstance().SendMessage(objMsg);
                }//end if
                else
                {//start else
                    //runs when document sharing starts from manage content slideshow page

                    string Extension = this.strExtension;//Path.GetExtension(DocumentFilePath);
                    Extension = Extension.ToLower();

                    if(Extension == ".doc" || Extension == ".docx")
                        documentType = DocumentMessageType.typeDocument;
                    else if(Extension == ".xls" || Extension == ".xlsx")
                        documentType = DocumentMessageType.typeExcel;
                    else if(Extension == ".ppt" || Extension == ".pptx")
                        documentType = DocumentMessageType.typePresentation;
                    else if(Extension == ".pdf")
                        documentType = DocumentMessageType.typePDF;

                    //					DocumentSharingEx docEx = new WebMeeting.Client.DocumentSharingEx(
                    //						documentType,this.sessionID,Info.getInstance().FtpIP,Info.getInstance().UserName,
                    //						Info.getInstance().Password,Info.getInstance().ConferenceID);

                    //					docEx.OnStatusUpdateFunction = new WebMeeting.Client.DocumentSharingEx.OnStatusUpdate(OnStatusUpdate);
                    //					MessageObject objMsg ;

                    //			docEx.DocumentShareStart(DocumentFilePath,out objMsg);

                    NetworkManager networkMngr = NetworkManager.getInstance();
                    WebMeeting.Common.DocumentSharing message = new WebMeeting.Common.DocumentSharing();
                    message.SenderID = networkMngr.profile.ClientId;
                    message.senderProfile = networkMngr.profile;
                    message.sessionID = this.sessionID;
                    message.DocumentSharingSessionId = this.sessionID;
                    message.DownloadURL = "Already Downloaded," + this.strRemoteUrl;
                    message.DocumentType = documentType;
                    message.CurrentPage=1;
                    message.TotalPages=this.no_of_pages;

                    /*if(!docEx.DocumentShareStart(DocumentFilePath,out objMsg))
                    {
                        //Handle the failure;
                        MeetingAlerts alert=new MeetingAlerts();
                        alert.ShowMessage(Alerts.MeetingAlerts.AlertType.Info,"Unable to upload document to webserver",true,false);
                        return;
                    }*/

                    IntializationCompleted = true;
                    //this.pictureCount = ((DocumentSharing)objMsg).TotalPages; //  by junaid for now
                    this.m_DocumentDownloaded=true;
                    this.ProcessMessageManageContent(message); //TODO:: optimized way is to add this mssg to poll and let thread do it
                    //but this causses file sharing error while same machine testing
                    this.m_DocumentMessage=	message;
                    message.DownloadURL="Already Downloaded," + message.DownloadURL;
                    //MessagePool.Add(objMsg);
                    NetworkManager.getInstance().SendMessage(message);
                }//end else

            }
            catch (WebException err)
            {
                WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("documentSharingControl.cs ==> DocumentSharingThread() line==> 1773",err,null,false);
                //MeetingAlerts alert=new MeetingAlerts();
                //alert.ShowMessage(Alerts.MeetingAlerts.AlertType.NonFatal,this.Name + " Class : DocumentSharingThread() function ," + ex.Source + " Source ," + ex.Message ,true,false);
            }

            finally
            {
                try
                {
                    theFile=new FileInfo(filenamed);
                    theFile.Delete();
                }
                catch(Exception exp){}
            }
        }