Get Already Purchased Product Data From App Store

Have you ever wanted to get previously brought product data(in app purchase) from app store while developing iPhone applications ??? Well, I wanted once. The application contained several products. And we needed to get those product details in a case user moves to a new device or he has couple of devices (iPhone, iPad) having the same app.

The answer is as follows, first you need to use the function

– (void)restoreCompletedTransactions

in SKPaymentQueue class. But your products need to be configured as non-consumable in app store.

After the transactions are delivered, the payment queue calls the observer’s

– (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue

method. If an error occurred while restoring

– (void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error

will be called.

After that you can check

@property(nonatomic, readonly) SKPaymentTransaction *originalTransaction

for each transaction and get the product id.

Searching for calendar view date picker for Android ???

When developing an Android application for Android 2.2, I needed to present a date picker having calendar view. Unfortunately prior to Android 3.1, Android SDK  has something like following.

Well, it’s not too bad but what if  you desperately need to provide a calendar view. Mine was something like that 🙂 So I did some search on web to find any open source controllers. I found several good controllers and out of them the best was http://code.google.com/p/android-calendar-view/ which is available under Apache license 2.0 . This is simple and easy to add in to our custom application. All the steps necessary to add this controller are listed under wiki at above URL.

More importantly this seems improving continuously which says this will be even better in future. Special thank goes for people who develop this. Good work, keep it up.

Selenium for automating web application UI testing

Selenium is an open source software which provides the functionality of automation testing for web applications. It supports lot of languages. Developers can benefit this  just having following three components

  • Selenium Remote Controller (Selenium RC)
  • Selenium IDE
  • Testing  Framework according to your language (Nunit for .net/Junit for java etc..)

Selenium RC  can automatically launch and kill browsers and execute tests in them. Most interesting component out of above is “Selenium IDE” which comes as a plugin for firefox. Developers just need to load their application into firefox, start the plugin and do whatever actions. Selenium IDE will record those actions and create a test case. Next you can export this test case to one of following language

  • C#
  • Java
  • Perl
  • PHP
  • Python
  • Ruby

Next you need to add this test case to your project. Selenium RC comes with plugins for support these languages. Go to the place where you extracted Selenium RC and you will see several plugins folders. In the case of C#, inside the plugins folder you will find several dll files. In the case of Java, it is couple of jars.

You can find enough tutorials of adding Selenium tests to a specific language. I’m just giving here an overview. Enjoy the benefits of Selenium 🙂

Google Doodles – super cool

“Google doodles, recently made me amazed couple of times. To a regular internet user the word “doodle” is not a  mystery. Anyway I will give a definition Doodles are the decorative changes made to the google logo in their search home page to celebrate special days, events all over the world. Over the last years they were just arts or static drawings that made the google home more memorable. But recently they seems like have new wings, more alive and dynamic. The best example was Les Paul doodle. Anybody imagined a playable guiter as a doodle?? Yeah, they did that. not only playing it but also recording a 30 seconds play.

This was a hit within entire world and guess, users has spent 10.7 million hours playing this doodle. Yeah you see the impact now 😀 So certainly it deserves the honour to have a permenant space in the web. If you wanna play it again , try http://www.google.com/logos/2011/lespaul.html

Before this Pac man doodle was also a hit. It made you possible to play pac man game in google home page. Well if you missed it, then here it is http://www.google.com/pacman/

If you have some time don’t forget to try these too, Jules vern doodle and martha graham doodle. They are cool, aren’t they. Just a reminder, don’t get over excited because  most amazing ones are yet to come. 

FINGERS CROSSED 😀 “

Build and Analyze a .net 4 project in Maven Sonar – Part 4

Now you need to configure sonar.properties file in sonar/conf.In this file you need to do some minor changes based on your project.  Those are changing the default database if you are not using derby and change username and password of your database.

#——————————————————–
# To use an environment variable, use the following syntax :  ${env:NAME_OF_ENV_VARIABLE}
# For example :
#   sonar.jdbc.url: ${env:SONAR_JDBC_URL}
#
#
# See also the file conf/wrapper.conf for JVM advanced settings
#———————————————————
#———————————————————
# WEB
# THESE SETTINGS ARE USED ONLY IN STANDALONE MODE. IGNORED WHEN THE WAR IS DEPLOYED ON A JEE SERVER.
#———————————————————
# Listen host/port and context path (for example / or /sonar). Default values are 0.0.0.0:9000/
#sonar.web.host:                           0.0.0.0
#sonar.web.port:                           9000
#sonar.web.context:                        /

# Log HTTP requests. Deactivated by default.
#sonar.web.jettyRequestLogs: ../../logs/jetty-yyyy_mm_dd.request.log

# Apache mod_jk connector. Supported only in standalone mode.
# Uncomment to activate AJP13 connector.
#sonar.ajp13.port: 8009

#———————————————————
# DATABASE
#———————————————————

#—– Embedded database
# Comment the following lines to deactivate the default embedded database (used only for tests and demos)
sonar.jdbc.url:                            jdbc:derby://localhost:1527/sonar;create=true
sonar.jdbc.driverClassName:                org.apache.derby.jdbc.ClientDriver
sonar.jdbc.validationQuery:                values(1)

# data directory, autodetected : /data if standalone application, /WEB-INF/classes/data if WAR deployement (exploded mode)
#sonar.embeddedDatabase.dataDir:
# derby embedded database server listening port, defaults to 1527
#sonar.derby.drda.portNumber:               1527

#—– MySQL 5.x/6.x
# Comment the embedded database and uncomment the following lines to use MySQL
#sonar.jdbc.url:                            jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
#sonar.jdbc.driverClassName:                com.mysql.jdbc.Driver
#sonar.jdbc.validationQuery:                select 1
#—– Oracle 10g/11g
# Comment the embedded database and uncomment the following lines to use Oracle
#sonar.jdbc.url:                            jdbc:oracle:thin:@localhost/XE
#sonar.jdbc.driverClassName:                oracle.jdbc.driver.OracleDriver
#sonar.jdbc.validationQuery:                select 1 from dual

# Activate if more than one Sonar Oracle schemas on the data server (for example different versions installed).
# In that case, use the same property during maven analysis (-Dsonar.hibernate.default_schema=xxx)
#sonar.hibernate.default_schema:            sonar

#—– PostgreSQL 8.x
# uncomment the 3 following lines to use PostgreSQL
#sonar.jdbc.url:                            jdbc:postgresql://localhost/sonar
#sonar.jdbc.driverClassName:                org.postgresql.Driver
#sonar.jdbc.validationQuery:                select 1
#—– Microsoft SQLServer
# The Jtds open source driver is available in extensions/jdbc-driver/mssql. More details on http://jtds.sourceforge.
# sonar.jdbc.url:                           

# sonar.jdbc.driverClassName:                net.sourceforge.jtds.jdbc.Driver
# sonar.jdbc.validationQuery:                select 1 
#—– Global database settings
sonar.jdbc.username:                       sonar 
sonar.jdbc.password:                       sonar
sonar.jdbc.maxActive:                      10
sonar.jdbc.maxIdle:                        5
sonar.jdbc.minIdle:                        2
sonar.jdbc.maxWait:                        5000
sonar.jdbc.minEvictableIdleTimeMillis:     600000
sonar.jdbc.timeBetweenEvictionRunsMillis:  30000

# Transaction isolation level. Default driver setting is used by default.
# Values : 1 (TRANSACTION_READ_UNCOMMITED), 2 (TRANSACTION_READ_COMMITTED), 4 (TRANSACTION_REPEATABLE_READ), 8 (TRANSACTION_SERIALIZABLE)
# sonar.jdbc.defaultTransactionIsolation: 2
# When packaged in a WAR, JDBC datasource can be configured into the application server then registered to JNDI.
# In such a case Sonar uses this datasource to connect to database, else if binds itself its own datasource.
# Note : Jonas does not accept to bind subcontexts, so name should be something like ‘jdbc-sonar’, without slashes.
# sonar.jdbc.jndiName:                       jdbc/sonar

# If you don’t use the default JDBC drivers, as listed above, then you have to explicitly set the dialect to use.
# Values are : mysql, derby, oracle, postgresql
# sonar.jdbc.dialect=
# ——————————————————–
# EXTENSIONS
# ——————————————————–
# Absolute path of coding rules extensions (custom rules that are not provided with tools like Checkstyle or PMD).
# This parameter is useful when Sonar is deployed as a WAR. It avoids from packaging the WAR file each time extensions JARs are updated.
# The directory contains subdirectories like checkstyle/ and pmd/
# Example :
# sonar.rules.extensionsPath:  /user/home/jdoe/sonar/extensions
# Example for windows platform (backslash char must be escaped) :
# sonar.rules.extensionsPath:  D:\\softwares\\sonar-1.8\\extensions

You are done with your configurations. Now show time, go to commnd prompt and enter following two commands

mvn clean install -Dtest=false -DfailIfNoTests=false

mvn sonar:sonar

All the best…………..!!!!!!!!!!!! 🙂

Build and Analyze a .net 4 project in Maven Sonar – Part 3

We have come to the final stages of the maven configuration. After we create settings.xml properly we are done with maven. It resides within M2_HOME/conf/.When you open the default settings.xml file, you will see that it has lot of lines and  most are commented. You just need to  add plugins at appropriate places. Keep other lines as they are. So the basic structure would be as following with dotnet and sonar plugins been added. Do necessary changes within plugins. Ex:- <galio.directory>, <sonar.jdbc.url> etc. Change them according to your installations and project properties.

<?xml version=”1.0″ encoding=”UTF-8″?>
<settings xmlns=”http://maven.apache.org/SETTINGS/1.0.0
          xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance
          xsi:schemaLocation=”http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd“>
 <profiles>
 <profile>
      <id>dotnet</id>
      <activation>
        <!– Optional activation by default –>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>

  <dotnet.4.0.sdk.directory>
  C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319</dotnet.4.0.sdk.directory>
             
        <!– Location of the Gallio installation –>
  <gallio.directory>
  C:\Program Files (x86)\Gallio</gallio.directory>

        <!– Location of StyleCop installation –>
        <stylecop.directory>
  C:\Program Files (x86)\Microsoft StyleCop 4.4.0.14</stylecop.directory>

        <!– Location of FxCop installation –>
        <fxcop.directory>
  C:\Program Files (x86)\Microsoft Fxcop 10.0</fxcop.directory>

        <!– Location of PartCover installation–>
        <partcover.directory>C:/Program Files (x86)/PartCover/PartCover .NET 4.0
  </partcover.directory>

        <!– Location of Source Monitor installation–>
  <sourcemonitor.directory>C:/Program Files (x86)/SourceMonitor
  </sourcemonitor.directory>
       
        <!– Location of Gendarme installation–>
  <gendarme.directory>C:/Program Files (x86)/Gendarme</gendarme.directory>
  
  <!– Location of NCover installation–>
  <ncover.directory>C:/Program Files/NCover</ncover.directory>
       
      </properties>
   </profile>
   <profile>
            <id>sonar</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
              
                <sonar.jdbc.url>jdbc:derby://localhost:1527/sonar;create=true
    </sonar.jdbc.url>
                <sonar.jdbc.driverClassName>org.apache.derby.jdbc.ClientDriver
    </sonar.jdbc.driverClassName>
                <sonar.jdbc.username>sonar</sonar.jdbc.username>
                <sonar.jdbc.password>sonar</sonar.jdbc.password>
    <sonar.host.url>http://localhost:9000</sonar.host.url&gt;
            </properties>
        </profile>
 </profiles>

</settings>

Next configuring sonar.properties file. After that we are done………………. 🙂

Build and Analyze a .net 4 project in Maven Sonar – Part 2

Time has come to  configure  maven. Before that run mvn –version in cmd and double check whether maven is installed correctly. if maven is ready next thing to do is creating the pom.xml file. Following is a sample pom.xml file for a .net 4 application. it includes all the necessary plugins. Below mentioned plugin versions are compatible with sonar 2.8 and maven 3.0.3. If you are using any other versions of maven or sonar(remember you should have atleast sonar 2.4 and maven 3.0) please check plugins’ compatibility, otherwise it would be a big headache.

<project xmlns=”http://maven.apache.org/POM/4.0.0&#8243; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd”&gt;
<modelVersion>4.0.0</modelVersion>
<groupId>org.codehaus.maven.dotnet.example</groupId>
<artifactId>example</artifactId>
<version>1.0-SNAPSHOT</version>
<name>YourProject</name>
<packaging>sln</packaging>
<properties>
<visual.studio.solution>YourProject.sln</visual.studio.solution>
<visual.test.project.pattern>*.Tests</visual.test.project.pattern>
<dotnet.tool.version>4.0</dotnet.tool.version>
<sonar.language>cs</sonar.language>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.sonar-plugins.dotnet</groupId>
<artifactId>maven-dotnet-plugin</artifactId>
<version>0.5</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.0-beta-2</version> <configuration>
<language>cs</language>
</configuration>
</plugin>
</plugins>
</build>
</project>

Now keep this in the folder where your .sln resides.You can see that I have defined two plugins in my pom. Those are maven-dotnet and sonar-maven. Be carefull there are two types of sonar-maven plugin, org.codehaus.mojo:sonar-maven-plugin and org.codehaus.sonar:sonar-maven-plugin. I’m using the first one because it make our lives easier. need to know how???? follow  http://docs.codehaus.org/display/SONAR/Frequently+Asked+Questions#FrequentlyAskedQuestions-Whatisthedifferencebetweenorg.codehaus.mojo%3Asonarmavenpluginandorg.codehaus.sonar%3Asonarmavenplugin%3F

Next you need to install several applications which are needed by maven-dotnet plugin. Those are

  • MsBuild
  • Gallio
  • PartCover
  • NCover
  • Source Monitor
  • Fx Cop
  • Style Cop
  • Mono Gendarme

http://maven-dotnet-plugin.appspot.com/usage.html provides a comprehensive guide of these applications. Configuring the settings.xml file in maven/conf is the next thing you must do………………………….let’s see that in the next blog post 🙂

Build and Analyze a .net 4 project in Maven Sonar – Part 1

Hi everyone, I recently build a .net4(C#) project using maven and analysed code quality reports using sonar.While doing so I searched the web for any comprehensive tutorials but found nothing.So I thought to share my knowledge withh you.I will describe the entire process step by step through couple of blog posts First we need to clarify basic requirements to build and analyze a .net 4 application.

  • JDK 1.6 (older versions are not compatible with maven-dotnet plugin, don’t worry  we are going to discover later all these plugins we need :))
  • Maven 3.0 or higher (older versions are not compatible with sonar-maven plugin)
  • Sonar 2.4 or higher (older versions are not compatible with sonar-dotnet plugin version 0.5. versions older than 0.3 are not compatible with .net 4 and version 0.4 is advised to ommit because it has a nasty error)
  • .net 4 framework

Now you know basic requirements. So install JDK 1.6, Maven 3.0 or higher and Sonar 2.4 or higher. Now configuring maven correctly………….it will be the next blog post 🙂

Why I started blogging????

Hi all !!!!.I’m Sameera Hasitha Bandara, an undergraduate of University of Moratuwa. This is the first blog post of my blogging life and I thought to share you with a nice story which  got from an e-mail.

Both the Sea of Galilee and the Dead Sea receive their water from river Jordan . And yet, they are very, very different.

Unlike the Dead Sea, the Sea of Galilee is pretty, resplendent with rich, colorful marine life. There are lots of plants. And lots of fish too. In fact, the sea of Galilee is home to over twenty different types of fishes.

Same region, same source of water, and yet while one sea is full of life, the other is dead. How come?

Here apparently is why. The River Jordan flows into the Sea of Galilee and then flows out. The water simply passes through the Sea of Galilee in and then out – and that keeps the Sea healthy and vibrant, teeming with marine life.

But the Dead Sea is so far below the mean sea level, that it has no outlet. The water flows in from the river Jordan , but does not flow out. There are no outlet streams. It is estimated that over a million tons of water evaporate from the Dead Sea every day. Leaving it salty. Too full of minerals. And unfit for any marine life.

The Dead Sea takes water from the River Jordan , and holds it. It does not give. Result? No life at all.

Think about it.

Life is not just about getting. Its about giving. We all need to be a bit like the Sea of Galilee .

We are fortunate to get wealth, knowledge, love and respect. But if we don’t learn to give, we could all end up like the Dead Sea . The love and the respect, the wealth and the knowledge could all evaporate. Like the water in the Dead Sea .

I want to be a Sea of Galilee :). So I will be sharing my knowledge, both technical and non technical here after.