JAJAH Development Blog

Blogs by JAJAH Developers

Archive for the ‘Tips, Tricks & Snippets’ Category

So you want to develop on Windows Mobile

Monday, May 18th, 2009
Windows Mobile 6.5 is done and that’s a good opportunity to provide a quick jump-start to developers wishing to learn more about the OS. WM_6_5Microsoft has a tendency to overload developers with abundant API of its various platforms and technologies. Windows Mobile is no different. Managed and native API, .Net, MFC, ATL, Win32… it’s all there for the confused developer. Luckily, Microsoft has recently published an article discussing APIs for Windows Mobile 6 and later, and how to select the best fit for your application needs. BTW, don’t be tempted to choose managed .Net API before fully understanding the functional requirements from your application and the devices it needs to run on. Win32 is better if you wish the application to run on as many devices as possible. A good place to learn Windows Mobile development is MSDN’s ramp up which is a community-based learning program, teaching various aspects in development for WM. Another excellent source for learning and help is blogs of mobile gurus. I recommend subscribing to the following blogs: Raffaele Limosaniblog, Alex Yakhnin, Christopher Fairbairn, Windows Mobile team blog, Reed and Steve blog, the Moth, and finally, Chris Craft (especially his 30 days of .Net series). OK. You’ve done your reading and fill ready to start developing? hold on. Make sure you took into account globalization and localization issues. Simon Judge lists many of them. Once done development, you need to QA your application. If your application aims for numerous devices in many countries, involving different networks, you should consider using DeviceAnywhere or maybe even Mob4Hire. Finished the cycle? congratulation! Now you can go and publish your application on Windows Marketplace.

Lenovo W500 Blue Screen of Death (BSoD), machine hangs and what makes great products great

Tuesday, March 31st, 2009
I recently got a new W500 Laptop (4062-2GX), while it’s supper fast and has a great display it is somewhat of a disappointed. As an avid ThinkPad users I can tell you – this is not an IBM laptop… it’s not built the same way my old T43 is built, and there are small things that make what used to be a great product into a good to very good product. It started with my W500 mouse getting hanged, drove me crazy, I reinstalled the OS, drivers, searched the web only to realize there’s a known hardware malfunction – it was replaced super fast (2 days), but yet I did not expect this from an IBM laptop. Than came the Blue Screens. After a while I decided it’s time to dig deeper and get this resolved. My Blue Screens where at iaStor.sys – to make a long story short there’s an Intel driver called AHCI driver that you can see here: image When you update your driver, or go to Windows Update it will look at Intel to see if this driver needs an update. But Surprise! while the Windows / Driver Update thinks your driver is updated there’s a new driver on Lenovo’s web site (which they are not too vocal about) Version #8.6.3 (which is newer than what I had from Intel) that you can download here: http://www-307.ibm.com/pc/support/site.wss/MIGR-70477.html Once I installed it BSoD are gone, at least for now… Putting all this aside there’s a great lesson for me as a developer – it is the small but annoying things that make the difference between a very good and an excellent product. Hope you find this helpful. Amichay

How to enable links to local files from your wiki on Firefox

Friday, March 13th, 2009
I like wiki. It’s a good platform to share information and ideas in your organization, community or the entire web. Occasionally, you’d like to add links to local files in your organization wiki like list of phone numbers, some how-to documents or something else. However, Firefox users find out that nothing happens when they’re clicking on the local-file links. This is actually due to security reasons. So, if you wish to override the behavior, this article will explain what to do.  The article suggests two add-ons to use. I prefer to LocalLink and not IE Tab because the later reloads the entire page on the IE engine and loses your logging session.
Meanwhile, on the wiki pages
The correct format for links to local files is to prefix the path with file:/// and wrap it with brackets. Let’s say your file resides in C:\MyFolder\MyFile.ext. The link in wiki will be edited as [file:///C:/MyFolder/MyFile.txt] (make sure to use slash and not backslash). In case the file resides in a server, the format will look like this: [file://///MyServer/MyFolder/MyFile.txt]  (did you noticed we’re now using 5 slashes?). After installing LocalLink you could open the file by right-clicking on the link and selecting from ‘Open Link in Local Context’ menu. LocalLinks You might consider setting your application configuration in Firefox. Go to Tools, Options and choose the Applications tab. Now, for each relevant file type, choose the action you want Firefox to take. ff_applications_options

How to add permanent links on WordPress

Sunday, March 8th, 2009
By default, WordPress posts have ugly links like http://yourpost.com/?p=12. It’s very easy changing the links to become more aesthetic and usable:
  1. Open your WP account.
  2. On the left-hand side, click on ‘Permalinks’ under ‘Settings’ options.
  3. Now choose the preferred settings
wp_permalinks

How to make conference calls from your mobile

Sunday, February 22nd, 2009
Did you know you can make conference calls from your mobile? Yes, we can! This functionality is hidden inside your phone and my guess is that 99% of mobile users are not aware of it. Here’s a quick step-by-step on how to do it on Nokia S40 phones. I welcome you to add in the comments explanations for other manufacturers.
  1. Call someone! (that’s easy, right?) and wait for your friend to answer. Let’s say his name is Riker.
  2. Press options, New call (ah ha!) and type the phone number of another friend. Let’s say his name is Worf. Wait for Worf to answer (Kapla!)
  3. Back on your phone, you’re now talking to Worf while Riker is on hold. Now press options, scroll down and press on – yes, you got it – Conference. Now you, Riker and Worf can speak all together.
  4. If you wish to add another friend - Data for example - simply repeat steps 2 and 3.
  5. To finish the conference just hang up. All your friends will be disconnected from the call.
A word of caution. You should check with your operator how much this calls will cost you. I’m not sure it’s just the rate of one call times the number of participants in the conference call. Finally, if you wish to make low-cost conference calls to friends and colleagues abroad, you can use JAJAH’s conference call service. If you’re not in front of your computer, you can make conference call as described above with JAJAH.Direct numbers.

How to run Freeswitch mod_dingaling on windows

Friday, February 13th, 2009
We recently began to explore Freeswitch. This is a powerful telephony platform that provides many communication functionalities with  agile configuration. Amongst others, we looked at the dingaling implementation which enables communications with GoogleTalk using XMPP implementation. We quickly found out there’re a few steps to complete before the code will run on Windows/VS environment. So, instead of having others struggle like we did, here’s a list of the required steps. Have fun.
  1. Configuration
    1. Enable mod_dingaling by un-commenting on modules.conf.xml the line <load module="mod_dingaling"/>. Alternatively, you can run on the console load mod_dingaling.
    2. Enable debug mode for the module (dingaling.conf.xml). It’s not required but will helps in understanding what’s going on.
    3. Create jingle-profile like the one below:
      <include>
        <!-- Remember to to remove the ‘x’ from x-profile -->
        <profile type="client">
          <param name="name" value="<meaningful name>"/>
          <param name="login" value="<your username>/gtalk"/>
          <param name="password" value="<your password>"/>
          <param name="server" value="talk.google.com"/>
          <param name="dialplan" value="XML"/>
          <param name="context" value="public"/>
          <param name="message" value="Send help or ? to learn more"/>
          <param name="rtp-ip" value="$${bind_server_ip}"/>
          <param name="ext-rtp-ip" value="$${external_rtp_ip}"/>
          <param name="auto-login" value="true"/>
          <!-- SASL "plain" or "md5? -->
          <param name="sasl" value="plain"/>
          <!-- Enable TLS or not -->
          <param name="tls" value="true"/>
          <!-- disable to trade async for more calls -->
          <param name="use-rtp-timer" value="true"/>
          <!-- default extension -->
          <param name="exten" value="1000"/>
          <param name="vad" value="both"/>
        </profile>
      </include>
      
  2. TLS. You need this to insure your XMPP stanzas are encrypted as required by the specifications. There’re few steps you need to do on windows:
    1. Install GnuTls for windows. Pick the latest exe file. At time of writing, the last one is 2.7.3.
    2. Assuming you’re using visual studio as your IDE, open visual studio command prompt (not your normal console) and type: cl foo.c -I../include -Dssize_t=long libgnutls-26.lib. This will create a libgnutls-26.lib that can be used as a import library for Visual Studio projects.
  3. Configure library ixemel to work with TL S libraries:
    1. Add additional include directory   addInclude
    2. Add additional dependency. addDependency
  4. Last step, make sure the TLS dlls are copied to the configuration environment. For example, if you’re running on debug mode, you should have the following files in <your freeswitch root>/Debug:
    • libgcrypt-11.dll
    • libgnutls-26.dll
    • libgnutls-extra-26.dll
    • libgnutls-openssl-26.dll
    • libgpg-error-0.dll
    • libtasn1-3.dll
    A post-build event should take care of it: xcopy "$(SolutionDir)GnuTLS-2.7.3\bin\*.dll" "$(SolutionDir)$(OutDir)\" /C /D /Y /S /F
  5. I-can’t-find-config.h-step. Copy it from <freeswitch root>\libs\win32\iksemel. Make sure the follwing line is not commented:
    #define HAVE_GNUTLS
  6. Questions?

C# 3.0: Lambda Expressions, extension methods and Object Initializers

Friday, January 23rd, 2009
I just finished reading Alex Yakhnin’s post about generic control creation for WinForms. This is an excellent article  for those whishing to know how to use some of C# 3.0 neatest features like Lambda Expressions, Extension Methods and Object Initializers. Alex demonstrate how, using these features, nerd developers like us can make their code more readable and as a result – maintainable. Basically, he used Extension methods to extends Control class functionality to create inherited controllers. One of the arguments used in the extension method is Func<Control, T> build.  This is a in fact a nice way to say that ‘build’ is a function that accepts an argument of  Control type, and has a return a value of type T. Next, he uses Lambda expression to present the function in an elegant way. The expression is in fact, a constructor for the control we wish to build. As a final ingredient in this wonderful code soup, he used Object Initializers for the constructor.

Hooking to keyboard in Windows Mobile

Tuesday, September 30th, 2008
Let’s say you built an application that need to know when certain keyboard buttons are pressed. Let’s say you need to get such events even while running the application in the background and some other application is running in the foreground. Well, there’s an easy to use native API that does that: SetWindowsHookEx. There’s an excellent post by Alex Yakhnin on how to use and integrate the method to managed application. However, before using the method, you should consider the following. The method is a private API. Meaning, it can change or even remove in the next CE version. More over, OEMs can decide to remove it themselves. The result is that you have angry customers complaining about your application and you have no idea why. For more information, check this post from Raffael Limosani of Microsoft CSS (Customer service and support). BTW, I highly recommends reading Raffael’s posts. They are very informative and to the point. So, you read the disclaimers and decide to continue and use the method. Alex’s code is excellent but there’re couple of points you need to consider. First of all, each button press initiates at least two events for the button. The first is for the state where the key is pressed (down). The other is of course, when the button is released (up). I decided to handle the down event in order to catch the event before other applications. That brings up to the second point. Other programs are also hooking. Usually, you don’t mind. Every time the hook procedure you set in SetWindowsHookEx is called, you do your stuff. When finished, pass the event to the next hook by calling the appropriately named method CallNextHookEx and return its result. However, if you wish to prevent the key event to pass to other hook, then don’t call CallNextHookEx. Instead, just return 0. Blocking other programs from these events is not very friendly behavior so thing carefully before doing it. On some cases, avoiding the call to CallNextHookEx might not be enough though. For example, the green (send) and red (end) buttons. It seems that the phone application catches events when these buttons are pressed even if you don’t call CallNextHookEx. If you wish to block that as well, have your hook procedure return -1. If you do return 0, expect the phone application to send another key up event upon completion of event processing. Don’t take my word for it. Try it for your self. Finally, don’t forget to call UnhookWindowsHookEx before closing your application or you’ll get a nasty error about WinCe5011bException.

Windows Mobile: Memory leaks and monitoring performance Tool (RPM)

Tuesday, August 19th, 2008
As most of you know, JAJAH released a pre-installed Windows Mobile VoIP client for the Japanese EMobile operator. While working on it, I checked for performance issues and memory leaks. This was critical since in addition to outgoing VoIP calls the application runs in the background and listens to incoming VoIP calls. In order to monitor the performance I used the .Net compact framework remote performance Monitor (RPM). this tool is easy to use, once you understand how to install and use it, and this is the reason for this post. Installation: copy netcfrtl.dll and netcflaunch.exe  from C:\ProgramFiles\Microsoft.NET\SDK\ CompactFramework\ v2.0\ WindowsCE\wce500\armv4i to the Windows directory on your device. (to copy from your desktop to your windows mobile device use ActiveSync) Running the PRM: Connect your device to the desktop using ActiveSync Open NetCFRPM.exe from C:\Program Files\Microsoft.NET\SDK\CompactFramework\v2.0\bin Select "File" and then "Live Counters" image In the device box select "ActiveSync"  and in the "application" box enter your application you wish to test. Press "connect". the application will start and you will see the changing counters. for more details about the counters check out David Kline’s post image image Using this view you can see the counters change and see what’s going on. to make things easier to monitor, you can have a view of the heap at real time and compare the GC heap at different intervals. imageGC Heap View: Click "View GC Heap" to view the heap status. In this view you can see the number of instances  each object has and the memory it consommes. you may also see the root object that is keeping the object alive, i.e. what is the object that holds a reference to the object and hence its not garbage collected. imageComparing heap states Its very helpfully comparing different heap states over time. This can help you see the difference in object over time and help you find leaks in various states of your application. When interested to know the heap state click "View GC Heap". when you want to compare the heaps memory states go to "View" and then select "Compare Heap". this view allows you to view the difference in object during the run time.

Profile your windows mobile application

Wednesday, August 6th, 2008
This post is aimed to windows mobile developers looking for a profiler for their mobile application. I came across EQATEC profile. This tool is great! You can run it on all .NET apps including .NET CF 2.0 and 3.5.  The usage is quite simple:
  1. Compile your application as usual. If you wish, you can later add profiler-attribute later for fine tuning the profiler.
  2. Use the profiler to build a profiled version of your application. The profiled assemblies are typically 30% larger than the original and runs 30% slower. I believe that for most apps that is acceptable. profiler
  3. Deploy the profiled version and run it on your device. Your device doesn’t have to be connected via the ActiveSync for this step. After the application finished, find the report file. Usually, it will be be on ‘Temp’ folder or on SD card if you have one.
  4. Drag the report file to your desktop, and from there, to the profiler viewer. profviewer
  5. After a few minutes, people around you would probably find you mumbling “OMG, what the…?, I didn’t believe it takes so much time! And why the hell this method is called so many times”.
I found the viewer useful for the following points:
  1. Find out your bottle-necks methods. This could be methods that takes long time to execute, or relativity fast methods that are called numerous times.
  2. Find out what happens inside your code. You might realize that you overlooked some calls to method that consumes most of the application time.
  3. Prioritize your work. The 80-20 rule will work here. You’ll find out that most of the delays are trackable and easy to resolve.
For more information and understanding on how to use the profiler, go to the guide. BTW, EQATEC also have a tracer tool. However, it is an on-line tool that drastically reduces the performance of your application. For example, the bubbles example application rate was reduced from 54 frames/seconds to 3!
Jajah is the VoIP player that brought you web-activated telephony.