Skip to main content

Posts

Showing posts from August, 2013

How to move or put the android button in the middle of the screen

Ques: How to centre buttons on screen horizontally and vertically ? Default Screen: Ans: You need to use a Relative Layout for android GUI in the activity_fullscreen.xml   or whatever you name it. You just need to add the android:layout_centerInParent="true" on your relative layout scope. In default android generate the layout as linear layout for your GUI activity. In that activity you can't use android:layout_centerInParent="true". It will generate warning as --- Invalid layout param in a LinearLayout: layout_centerInParent    activity_fullscreen.xml    /YourProject/res/layout    line 52    Android Lint Problem How?:    Step 1. First open the layout xml from /YourProject/res/layout . Step 2. Change all of the <FrameLayout> ... </FrameLayout> to <RelativeLayout> ... </RelativeLayout> .  Step 3.  Delete default button code porti...

Threaded multi Chat room client source code in c++ with MFC Part - 3

PREVIOUS ClientDlg.cpp is the class where all the action from user's are taken and initiated. The interaction with GUI to logic is so great and easy which will help any developer to understand the flow of code. Function for login -- void CClientDlg::OnBnClickedButton2() {     // TODO: Add your control notification handler code here     cTh = AfxBeginThread(     StaticThreadFunc,     this);         m_Thread_handle = cTh->m_hThread; } Start the thread for a login action. UINT __cdecl CClientDlg::StaticThreadFunc(LPVOID pParam) {     CClientDlg *pYourClass = reinterpret_cast<CClientDlg*>(pParam);     UINT retCode = pYourClass->ThreadFunc();     return retCode; } UINT CClientDlg::ThreadFunc() {     // Do your thing, this thread now has access to all the classes member variables     ...

Threaded multi Chat room client source code in c++ with MFC Part - 2

PREVIOUS                                                                                                                                NEXT Client.cpp class is the MFC GUI initiation class. You can have a look here .. BOOL CClientApp::InitInstance() {     // InitCommonControlsEx() is required on Windows XP if an application   ...

Threaded multi Chat room client source code in c++ with MFC Part - 1

As in my previous post I have talk about server , now it's time for client. This client will use as multi chat client with our very own server. In this client you need to provide server IP , PORT and an USERNAME . Then just click the log in button and you are in if you get an welcome message from server. Technology used: i.   C++ ii.   Microsoft visual Studio 2010 iii.  MFC GUI iv.  Winshock2 Socket v.   TCP/UDP vi.  Windows Thread This project consist of  3 classes. 1. Client.cpp 2. ClientDlg.cpp 3. ClientCon.cpp Lets start with core portion -- I mean the network level connection portion. I have used the Winshock2 library for the purpose of network communication. You can use this library on windows  with MVS 2010 by including library -- # include <winsock2.h> And as it is multi user  and have GUI so we need thread. For this I have used Windows thread. You can use this windows thr...

Threaded multi chat room server source code in c++ with MFC Part - 3

PREVIOUS   Now we will talk about the other MFC GUI portion which I have created and used threaded model. When in GUI the start button is clicked by providing port number on PORT text box this server start by creating a thread independent from GUI. You can start the server by ENTER also. Here is some code snap for help -- void CServerDlg::OnBnClickedButton1() {     // TODO: Add your control notification handler code here     cTh = AfxBeginThread(     StaticThreadFunc,     this);         //cTh->m_bAutoDelete = FALSE;     m_Thread_handle = cTh->m_hThread;     } Here we create a windows thread for back end action. UINT __cdecl CServerDlg::StaticThreadFunc(LPVOID pParam) {     CServerDlg *pYourClass = reinterpret_cast<CServerDlg*>(pParam);     UINT retCode = pYourClass->ThreadFunc(); ...

Threaded multi chat room server source code in c++ with MFC Part - 2

PREVIOUS  we will now demonstrate about the class Server.cpp . This class is the start point of the server project. It is basically used to call the MFC instance. There will be some preview of the class here as MFC is out of scope  at the moment -- BOOL CServerApp::InitInstance() {     // InitCommonControlsEx() is required on Windows XP if an application     // manifest specifies use of ComCtl32.dll version 6 or later to enable     // visual styles.  Otherwise, any window creation will fail.     INITCOMMONCONTROLSEX InitCtrls;     InitCtrls.dwSize = sizeof(InitCtrls);     // Set this to include all the common control classes you want to use     // in your application.     InitCtrls.dwICC = ICC_WIN95_CLASSES;     InitCommonControlsEx(&InitCtrls);     CWinApp::InitInstance();   ...

Threaded multi chat room server source code in c++ with MFC Part - 1

Multi-client chat server is open source as I have created it. In this server multiple user can log in and communicate with one another as multicast user. In reality it can use as a chat room server. Can be modified as peer to peer (p2p) text chat. It can also be used as a backbone of a video conferencing project. It has a beautiful and easy to use user interface in MFC. This project is compatible with Microsoft visual studio 2010. I will describe the use of class and function with source code. Technology used: i.   C++ ii.   Microsoft visual Studio 2010 iii.  MFC GUI iv.  Winshock2 Socket v.   TCP/UDP vi.  Windows Thread This project consist of  3 classes. 1. Server.cpp 2. ServerDlg.cpp 3. ServerManager.cpp Lets start with core portion -- I mean the network level connection portion. I have used the Winshock2 library for the purpose of network communication. You can use this library on windows  with MVS 2...

How to take input from a MFC Edit Control as string, convert it to integer and append text to it

 Take input from a MFC Control as string : CString txtname; GetDlgItemText(IDC_EDIT1, txtname); Here IDC_EDIT1 is the Control Edit Text and txtname is the input at the moment we call. Convert it to integer or int : int iPort = _atoi( txtname.GetString() ); int iPort = _wtoi( txtname.GetString() ); // if you use wide charater formats     Append text to Edit Control :   void CServerDlg::AppendTextToEditCtrl(CEdit& edit, LPCTSTR pszText) {    // get the initial text length    int nLength = edit.GetWindowTextLength();    // put the selection at the end of text    edit.SetSel(nLength, nLength);    // replace the selection    edit.ReplaceSel(pszText); }

How to stop a blocking thread from another function that start in other in MFC

ISSUE: In server client scenario it is mandatory to use thread where sever is listening on a particular port. Now in click of stop button ,how to stop this running thread. SOLUTION: #include <Windows.h> HANDLE m_Thread_handle; CWinThread *cTh; static UINT __cdecl StaticThreadFunc(LPVOID pParam); UINT ThreadFunc(); Step 1. Declared these on header file. Step 2. Starting the thread from a function or button click --- void CServerDlg::OnBnClickedStart() {     // TODO: Add your control notification handler code here     cTh = AfxBeginThread(     StaticThreadFunc,     this);     m_Thread_handle = cTh->m_hThread; } Step 3. Thread initialization function --  UINT __cdecl CServerDlg::StaticThreadFunc(LPVOID pParam) {     CServerDlg *pYourClass = reinterpret_cast<CServerDlg*>(pParam);     UINT retCode = pYourClass->ThreadFunc();   ...

This Android SDK requires Android Developer Toolkit version 22.0.0 or above.

ISSUE: This Android SDK requires Android Developer Toolkit version 22.0.0 or above.  Current version is 21.1.0.2013-2-6-0-46.  Please update ADT to the latest version. SOLUTION: Run Eclipse as administrator . Go to Help → Install New Software . On Work with: type https://dl-ssl.google.com/android/eclipse/ and press ENTER. Wait for Eclipse to fetch the repository. An item named Developer tools will appear in the list. Mark it for install, press Next and follow the steps to install the ADT tools. When finished, it will ask to restart Eclipse. Make sure you do this. When Eclipse restarts, all your Android SDK packages should show up again.

GUI hanged on button pressed or some action initiation in MFC project

ISSUE: In a GUI project there is lots of calculation and works are needed to be done in background when necessary . So when a button pressed or a certain action initiate the GUI may stop responding for you. SOLUTION: In default when a MFC project is created the GUI portion has thread. So make sure the other necessary works are done on another thread (eg: calculation, process, response , internet query ). You can have a better and great idea about thread use in mfc from this simple post

Best design for windows multi thread in a c++ class

ISSUE: How to create windows multi-threaded program in  c++ ? SOLUTION:   Now a day maximum project or software has multiple process running at a same process.Or a gui application needs to do some work on background which is blocking. Or may be you are going to design or create a network application ,so it becomes mandatory to be an expert of Threading now a days. Here is  the template which I follow. In header file add the followings -- #include <Windows.h> static UINT __cdecl CallingFunctionForThread ( LPVOID pParam ); UINT WorkingFunction ();   In CPP file add the followings -- UINT __cdecl My Class :: CallingFunctionForThread ( LPVOID pParam ) { My Class * pMy Class = reinterpret_cast < My Class *>( pParam ); UINT ret = pMy Class -> WorkingFunction (); return ret ; } UINT My Class :: WorkingFunction () { // You can do anything as a class member function and run it on your thread. } Start ...

How to convert between 'CString' and 'std::string' ?

ISSUE: When you are developing MFC project in most cases it becomes necessary to convert between 'CString' and 'std::string' . SOLUTION: 'CString' to 'std::string': CString sTest ( "Matrix" ); // Convert a TCHAR string to a LPCSTR CT2CA CStringToAscii(sTest); // construct a std::string using the LPCSTR input std::string sResultedString (CStringToAscii); 'std::string' to 'CString': std::string sTest( " Matrix " ); CString ResultedCString(sTest.c_str());  

IntelliSense: #error directive: Please use the /MD switch for _AFXDLL builds in Visual Studio 2010 MFC project

ERROR:     error C2001: newline in constant IntelliSense: #error directive: Please use the /MD switch for _AFXDLL builds    c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxver_.h    81    3     Solution: There's a bug where the settings of a generated MFC project would show "Multi-threaded Debug DLL (/MDd)"; however, it doesn't pass that argument to the intellisense engine. To workaround this problem, please try the following: Step 1. Right-click the Project. Step 2. Go to Config Properties->C/C++-> Code Gen ->. Double-click "Runtime Library" and set to "Multi-threaded Debug DLL (/MDd)" . If this value already appears to be set, make sure it is by selecting it again (it should then appear as bold). Step 3. Click OK. Done!

Lync 2010 client does not login in Lync 2013 server

ISSUE:   Lync 2010 client does not login in Lync 2013 server. CAUSE:   The cause may be following one from 3. i.   Client version filter in Lync SERVER ii.  Network Security: Minimum session security in Lync SERVER SOLUTION: i.   Client version filter in Lync SERVER :  Here ii.  Network Security: Minimum session security in Lync SERVER :  Here

Set NTLM authentication as first choice in lync 2010/2013 server

ISSUE: How to set authentication support NTLM in lync 2010/2013 server as first choice ? SOLUTION: Step 1. Run secpol.msc on Lync Front End server Step 2. Select Local Policies  -> Security Options Step 3. Open Network Security: Minimum session security for NTLM SSP based (including secure RPC) Step 4. Tick on Require NTLMv2 session security (default Require 128-bit encryption) Step 5.  Open second Network Security: Minimum session security for NTLM SSP based (including secure RPC) Step 6. Tick on Require NTLMv2 session security (default Require 128-bit encryption) You are done!

How to disable/enable client version filter on Microsoft lync server 2010/2013

ISSUE: How to disable/enable cleint version filter on Microsoft lync server 2010/2013 SOLUTION: Go to lync server front end. Then open lync server control panel. In the left navigation bar, click Clients , and then click Client Version Configuration . On the Client Version Configuration page, double-click the Global configuration in the list. In the Edit Client Version Configuration dialog box, verify that the Enable version control check box is selected and then, under Default action , select one of the following: Allow    Allows the client to log on if the client version does not match any filter in the Client version policies list. Block    Prevents the client from logging on if the client version does not match any filter in the Client version policies list. Block with URL    Prevents the client from logging on if the client version does not match any filter in the Client version policies list,...

SIP/2.0 415 Unsupported Media Type - in lync

ISSUE:   When a lync client make a call to a custom client this issue arise. SIP/2.0 415 Unsupported Media Type Via: SIP/2.0/TLS 192.168.0.3:5061;branch=z9hG4bKD46A59CA.99BC04A5AF342A99;branched=FALSE;ms-internal-info="beEdEaEIWfaYJeF8c6BZ3b0XKNdvQ3PyQaRPEpAEarjbWlBLyZ_eZHbgAA" Via: SIP/2.0/TLS 192.168.0.4:55803;branch=z9hG4bK36072482.06B5227EC88DCA9A;branched=FALSE;ms-received-port=55803;ms-received-cid=162D00 Via: SIP/2.0/TLS 192.168.0.100:50797;received=x.x.x.x;ms-received-port=50797;ms-received-cid=8C00 Record-Route: <sip:FE.domain.local:5061;transport=tls;opaque=state:T:F:Ci.R16a800;lr;ms-route-sig=adlkYhe7OeBeVys8TvobWpLmx2HSLx-xldaLJ-jRlgx4mlBLyZI12ObwAA>;tag=D5120ECF36260EB267FB812D17DAE391 From: "Test User 3" <sip:test3@fe.local>;tag=be345768e2;epid=3bcd1d97b8 To: <sip:demouser@fe.local>;epid=13757352 Call-ID: ff8f03c39c46499db228eab1eb58fed9 CSeq: 1 INVITE Authorization: NTLM qop="auth", realm="SIP Communications ...

SIP/2.0 481 Call Leg Does Not Exist -- in lync

ISSUE 1: When make a call in lync client after certain message transaction lync caller get 481 Call Leg Does Not Exist . SIP/2.0 481 Call Leg Does Not Exist Authentication-Info: NTLM qop="auth", opaque="9436E22E", srand="8E281C5D", snum="12", rspauth="010000002be81caccb7d825264000000", targetname="FE.domain.local", realm="SIP Communications Service", version=4 From: <sip:demouser@edge.com>;tag=1375799463;epid=13757994 To: <sip:test3@fe.local>;tag=D5120ECF36260EB267FB812D17DAE391 Call-ID: 2jXhMAF7GVJhUA2Y8r4181MM6OlpCbvsjhzTH2Oc CSeq: 1 CANCEL Via: SIP/2.0/TLS x.x.x.x:59631;branch=2OyLJ5KO1GNvDbbGyOpb1pn8l2F1tFUmjiVRcvv1;received=192.168.0.101;ms-received-port=59631;ms-received-cid=1B2E00 ms-diagnostics: 2;reason="See response code and reason phrase";HRESULT="0xC3E93C09(PE_E_TRANSACTION_DOES_NOT_EXIST)";source="FE.domain.local" Server: RTC/4.0 Content-Length: 0...

How to enable HD video in Microsoft Lync

ISSUE:   You can change video resolution on lync client by increasing/decreasing the capture window size. The video resolution change can be either of these following type --       1. QCIF (176×144) 15fps       2. CIF (352×288) 15fps       3. VGA (640×480) 15fps       4. HD (1280×720) 13fps  The default video resolution set on lync server normally is VGA . 1. How to know about it? The answer is here . 2. How to change video resolution it? Open lync server management shell in administrator mode. Now give following command --- Set-CsMediaConfiguration –Identity Global -MaxVideoRateAllowed Hd720p15M The underline attribute can be either Hd720p15M, VGA600K, and CIF250K. 3. How to make sure that configuration is applied? The answer in here .

How to know about current maximum video resolution supported by lync server

There are 2 possible way to know about video resolution configuration. 1. The hard way -- from lync server management shell. Open lync server management shell in administrator mode. Now give following command --- Get-CsMediaConfiguration –Identity Global Output:   2. Easy way -- smart way from lync client uccapi log with out lync server. Open uccapi log of lync client from Tracing folder . Now search by <ucMaxVideoRateAllowed> .You will see that like --- <ucMaxFileTransferPort>5389</ucMaxFileTransferPort> <ucPC2PCAVEncryption>SupportEncryption</ucPC2PCAVEncryption> <ucMaxVideoRateAllowed> Hd720p-1.5M </ucMaxVideoRateAllowed> <qosEnabled>true</qosEnabled> <ucDiffServVoice>40</ucDiffServVoice> <ucVoice802_1p>0</ucVoice802_1p> Which is your current video resolution configuration. To change it please follow the procedure describe on here.

400 Malformed route header --"Parsing failure" in federated lync support

ISSUE:    When a lync user start call negotiation with federated user this 400 Malformed route header problem arise. WHY? As the federated user's are most of the case out of the local lync server and they are not the user of this local lync server edge end, they often need clear and concrete route header so that server could extract route header value in-order and route the message to remote federated client end. Example: Sending: CANCEL sip:demouser@yy.com;opaque=user:epid:SsEhlbS7GFGJkfHOY836rAAA;gruu SIP/2.0 Via: SIP/2.0/TLS x.x.x.x:33360;branch=18n2L9K88eMlGn7CcctT9RwKSB1FebW397VI5uG1 From: <sip:test@xx.local>;tag=1375467581;epid=13754675 To: <sip:demouser@yy.com>;epid=fd941b3907;tag=9c85c700e3 Call-ID: BHQjMXffBDJ3cWfS4CAvb2wTByEnCZT2xxb7jecK CSeq: 2 CANCEL Max-Forwards: 70 User-Agent: Matrix 1. Route: <sip:ddd.yy.local:5061;transport=tls;opaque=state:T;lr> 2. Route: <sip:sip.yy.com:5061;transport=tls;epid=fd941b3907;lr;ms-key-info=AAEAA...

488 Not Acceptable Here. - "Client side general processing error." in lync

ISSUE:   This issue arise when any user make a call to other lync user. In summary when there is a issue of INVITE message transaction.  WHY? 488 Not Acceptable Here   issue arise due to sdp misconstruction or for invalid sdp.  Sending: INVITE sip:demouser@yy.com SIP/2.0 Via: SIP/2.0/TLS x.x.x.x:33360;branch=18n2L9K88eMlGn7CcctT9RwKSB1FebW397VI5uG1 From: <sip:test@xx.local>;tag=1375467581;epid=13754675 To: <sip:demouser@yy.com> Call-ID: BHQjMXffBDJ3cWfS4CAvb2wTByEnCZT2xxb7jecK CSeq: 1 INVITE Contact: <sip:test@xx.local;opaque=user:epid:DbsgHp_PWlGCoMke5u6QsgAA;gruu> Content-Type: application/sdp Max-Forwards: 70 Supported: ms-dialog-route-set-update Supported: timer Supported: histinfo Supported: ms-safe-transfer Supported: ms-sender Supported: ms-early-media Supported: 100rel Supported: replaces Supported: ms-conf-invite Ms-keep-alive: UAC;hop-hop=yes Accept-Language: en-US P-Preferred-Identity: sip:test@xx.local Allo...

DTMF or Telephony event support on SDP and in RTP in Microsoft lync audio conference

DTMF (Dual Tone Multi Frequency) is a type of signaling used primarily in voice telephony systems. It features audible tones in the frequency range of the human voice which are typically used when dialing a call (on analog lines) or when operating an IVR menu. There are many other applications for this signaling. For more information, see the wikipedia article on DTMF ( http://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling ) DTMF RTP: A dtmf packet is 16 bytes. DTMF data = 12 bytes (RTP header) + 4 bytes (RTP payload) 4 bytes (RTP payload) has mapping of key press value as event. After parsing this 4 bytes the receiver end can get instruction or event what to do. DTMF SDP:              dtmf payload is 101 . It is passed on audio level of lync SDP. m=audio 5476 RTP/AVP 101 . . . a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16  a=fmtp:101 0-16  indicates the key value that is supported...

cannot sign into communicator because your computer clock is not setup correctly

  ISSUE:   cannot sign into communicator because your  computer clock is not setup correctly !!! WHY? This issue arise when lync server's directory control ( DC ) clock time is not match up with Lync Client 's pc clock time. SOLUTION: The easy solution is that to make sure that the Lync DC system time is maximum 5 minute different then Client's PC time. The smart solution is -- STEP 1. Goto  client pc's adjust date and time . STEP 2.  Then on Date and Time window select Internet Time tab. STEP 3. Now click on Change settings..   a new pop-up named Internet Time Settings will arise. STEP 4. On Server   text field set the Lync DC / active directory IP address and click update now . STEP 5. Now you will get DC system time and set it by clicking OK .

How to export sip and a/v certificate from lync server and edge server in lync 2010/2013.

To enable a lync user 3 certificates are necessary. These certificates are exported from lync server, edge server and directory control. Certificate for specific services: 0. Root CA 1. SIP services/Lync Front-end. 2. AV services/Edge . 1. SIP services. : STEP 1.   Goto run in windows button in lower left corner and type mmc . STEP 2.   In mmc window selecte File-->Add/Remove snap-in. STEP 3.   Select Certificates from Add/Remove snap-in.   STEP 4.   Select Computer Account from Certificate Snap-in. STEP 5.    Click Next and do all of the necessary stuff on the way. STEP 6.   Select Personal->certificates from  mmc console. STEP 7.   After that select the certificate you need to export and click right button of mouse and from All Tasks select export . STEP 8.   Just follow necessary stuff and get your certificate by instruction from next click. For Edge server certificate follow the...

How to export root certificate from directory control in lync 2010/2013.

To enable a lync user 3 certificates are necessary. These certificates are exported from lync server, edge server and directory control. Certificate for specific services: 0. Root CA 1. SIP services. 2. AV/Edge services. 0. Root CA: You can get it from lync dc or directory control. Most of the case it is windows 2008 R2 sevrver edition. STEP 1. Open IIS Manager from all programs and navigate to the level you want to manage. STEP 2.   In Features View , double-click Server Certificates . STEP 3.   Select a certificate and click View from the Actions pane.   STEP 4. In view certificate go to details tab and click on  copy data to file . STEP 5.   Now click Next , give certificate save  location and select all of the necessary  attribute on the way.                            ...