Untiny & Ubiquity

Posted October 11th @ 7:17 pm by da-crystal

image Unitny is a web service that does the opposite of what ‘tiny’ sites do. It simply returns the original Url for a given shortened Url. Why? Why not use the shortened URL? The main reason is, in some countries, some ISP’s are blocking this kind of sites (tiny sites) for a claim of security issue.

Here is where Saleh Alzaid came with a legal idea in those ISP point of view, to solve that issue. Simple, convenient and cleaver those words can describe the Unitny service.

Since Unitny’s API makes the development possible and handy, many Unitny’s users have developed add-ons/plug-ins for a variety of OSs and/or software. Because I loved the Idea of Unitny and I like trying something new(like Ubiquity) I made a Ubiquity command (“untiny”) that uses the Unitny service.

image

First of all if you don’t know what Ubiquity is then visit Ubiquity’s web site. If you already have Ubiquity, you might notice the subscription notification while you are in this page.

image

On how to use it, there are many ways to use Ubiquity command. The easiest way, is to highlight the link then use the Ubiquity combination, “ctrl+space” is the default, then type “untiny”. The preview of the command will show the original URL. While executing the command will open the original URL.

image

Have a nice Unitny day :D

Windows Live Installer (WLInstaller) behind proxy!

Posted August 20th @ 12:30 pm by da-crystal

WLI-Behind Proxy

I know most of you hate Windows Live Installer, Like I do.  Because it dose not work behind a proxy without the ways that will be described in this post.

WinHTTP:

After debugging WLInstaller, I found out it uses WinHTTP modules to get MSI information and packages.  And as you might know WinHTTP is a Windows service that can be configure using other utilities.

WinHTTP Configuration Utilities:

  • ProxyCfg (Pre Vista OS, e.g. XP)
  • NetSH  (Vista OS)

ProxyCfg:

  • Make sure to configure your Internet Explorer to work with your current proxy and your credential have been saved (if your proxy uses one).
  • Open the Command Prompt
  • Type “proxycfg -u”,  then press ‘Enter’
  • Close Command Prompt

ProxyCfg

thanks Snakodus

NetSh:

  • Make sure to configure your Internet Explorer to work with your current proxy and your credential have been saved (if your proxy uses one).
  • Open Command Prompt
  • Type “netsh winhttp import proxy source=ie”,  then press ‘Enter’
  • Close the Command Prompt

NetSh

And that’s it now open WLInstaller and enjoy Micro$oft products :)

WLI- WinHttp

Polygamify Your Windows Live Messenger (Multi-MSN)

Posted August 19th @ 7:48 pm by da-crystal

Many people out there are using Windows Live Messenger as IM, and for some reason they need to open more than one instance (polygamy).  But that does not work without a patch for Windows Live Messenger.  In this post, I’ll explain how to patch your own Windows Live Messenger by yourself.  Some may say there are patches already exist out there, my answer; I don’t trust it because it might contain Spyware :) .

 

Tools:

  • Debugger (OllyDbg)  {for the dirty work} :p
  • Hex Editor (xvi32)  {if you know the address for the magic line}

 

The short way (for WLM 8.5):

  • Copy & Rename Windows Live Messenger “msnmsgr.exe” to something else; let say “msnmsgr-multi.exe”
  • Open msnmsgr-multi.exe by Hex Editor (maybe xvi32)
  • Go to Address {8CF06}
  • Replace {0F 84 BA 77 00 00}
  • With {90 90 90 90 90 90}
  • Save it!
  • That’s it, enjoy your Window Live Messenger

 

The long way (if you don’t know the magic address!):

  • Open OllyDbg
  • then Open then “msnmsgr.exe”
  • Open “intermodular calls”; By right-click on CPU Window –> Search For –> All intermodular calls
  • Sort “intermodular calls” by “Destination”, then type “CreateEvent”

 Intermodular Calls

  • Click the first “CreateEvent” to highlight it in CPU Window
  • You will notice Eventname of CreateEvent is “MSNMSGR”,  locate the GetLastError that come after our CreateEvent 

image

  • Our magic line is the 2nd line after GetLastError  {JE xxxxxxxx}.   x = hex number
  • Double-Click that line then replace {JE xxxxxxxx} with {nop} and make sure “Fill With NOP’s” is Checked then click Assemble then Cancel

image

  • Now we are done, the only thing left is to save the changes; right-click in CPU Window; Copy to executable –> All modification; then select “Copy All”
  • Then from the window that poped up; right-click –> save to file –> rename it if you want ( I usually do, in case I need the original one) , let say “msnmsgr-multi.exe”
  • Close OllyDbg and enjoy your Windows Live Messenger
Comments Off

CheckBox in QComboBox

Posted June 5th @ 2:05 am by da-crystal

Qt is one of the best GUI Widget cross-platform libraries that I ever worked with ;) .

clip_image002

 

At some point, I was in need for a Combo box with a list of Checkbox item.  And that had not been provided as out-of- shelf widget.  For some reason, one of them as in the following quotes:

 “a combo box is a way to represent a single selection, not to hide other GUI elements”.

First let understand the QComboBox. The Combo box usually has two main parts:  current item view and items view (popup) .  Current view is view displaying the selected item.  While items view display a list of items to be select. 

Now let work with the items view to handle item as checkbox rather than a label ;) .  In order to customize our items view we need to assignee an item delegate to the items view.   And that led us to create a customized (inherited) QItemDelegate let called CheckBoxListDelegate:

 

class CheckBoxListDelegate : public QItemDelegate

{

public:

    CheckBoxListDelegate(QObject *parent)

             : QItemDelegate(parent)

      {

            ;

      }

 

      void paint(QPainter *painter, const QStyleOptionViewItem &option,

                          const QModelIndex &index) const

      {

            //Get item data

            bool value = index.data(Qt::UserRole).toBool();

            QString text = index.data(Qt::DisplayRole).toString();

           

            // fill style options with item data

            const QStyle *style = QApplication::style();

            QStyleOptionButton opt;

            opt.state |= value ? QStyle::State_On : QStyle::State_Off;

            opt.state |= QStyle::State_Enabled;

            opt.text = text;

            opt.rect = option.rect;

 

            // draw item data as CheckBox

            style->drawControl(QStyle::CE_CheckBox,&opt,painter);

      }

 

    QWidget *createEditor(QWidget *parent,

             const QStyleOptionViewItem & option ,

             const QModelIndex & index ) const

      {

            // create check box as our editor

             QCheckBox *editor = new QCheckBox(parent);

             return editor;

      }

 

       void setEditorData(QWidget *editor,

                                                             const QModelIndex &index) const

       {

             //set editor data

             QCheckBox *myEditor = static_cast<QCheckBox*>(editor);

             myEditor->setText(index.data(Qt::DisplayRole).toString());

             myEditor->setChecked(index.data(Qt::UserRole).toBool());

       }

 

       void setModelData(QWidget *editor, QAbstractItemModel *model,

                                                            const QModelIndex &index) const

       {

             //get the value from the editor (CheckBox)

             QCheckBox *myEditor = static_cast<QCheckBox*>(editor);

             bool value = myEditor->isChecked();

 

             //set model data

             QMap<int,QVariant> data;

             data.insert(Qt::DisplayRole,myEditor->text());

             data.insert(Qt::UserRole,value);

             model->setItemData(index,data);

       }

 

       void updateEditorGeometry(QWidget *editor,

             const QStyleOptionViewItem &option, const QModelIndex &index ) const

       {

             editor->setGeometry(option.rect);

       }

 };

 

Then we need to tell our combo box to use that delegate as default delegate for the items view that it own.   Also we need to change the way it display the selected item.  Header of our CheckBoxList will look like:

class CheckBoxList: public QComboBox

{

      Q_OBJECT;

 

public:

      CheckBoxList(QWidget *widget = 0);

      virtual ~CheckBoxList();

      bool eventFilter(QObject *object, QEvent *event);

      virtual void paintEvent(QPaintEvent *);

      void SetDisplayText(QString text);

      QString GetDisplayText() const;

 

private:

      QString m_DisplayText;

};    

 

And the implementation:

CheckBoxList::CheckBoxList(QWidget *widget )

:QComboBox(widget),m_DisplayText(0)

{

      // set delegate items view

      view()->setItemDelegate(new CheckBoxListDelegate(this));

     

      // Enable editing on items view

      view()->setEditTriggers(QAbstractItemView::CurrentChanged);

     

      // set "CheckBoxList::eventFilter" as event filter for items view

      view()->viewport()->installEventFilter(this);

     

      // it just cool to have it as defualt ;)

      view()->setAlternatingRowColors(true);

}

 

 

CheckBoxList::~CheckBoxList()

{

      ;

}

 

 

bool CheckBoxList::eventFilter(QObject *object, QEvent *event)

{

      // don’t close items view after we release the mouse button

      // by simple eating MouseButtonRelease in viewport of items view

      if(event->type() == QEvent::MouseButtonRelease && object==view()->viewport())

      {

            return true;

      }

      return QComboBox::eventFilter(object,event);

}

 

 

void CheckBoxList::paintEvent(QPaintEvent *)

{

    QStylePainter painter(this);

    painter.setPen(palette().color(QPalette::Text));

 

    // draw the combobox frame, focusrect and selected etc.

    QStyleOptionComboBox opt;

    initStyleOption(&opt);

 

      // if no display text been set , use "…" as default

      if(m_DisplayText.isNull())

            opt.currentText = "…";

      else

            opt.currentText = m_DisplayText;

    painter.drawComplexControl(QStyle::CC_ComboBox, opt);

 

    // draw the icon and text

    painter.drawControl(QStyle::CE_ComboBoxLabel, opt);

}

 

 

void CheckBoxList::SetDisplayText(QString text)

{

      m_DisplayText = text;

}

 

QString CheckBoxList::GetDisplayText() const

{

      return m_DisplayText;

}

 

And that’s it ;) see it in action:

      CheckBoxList list;

      list.addItem("Qt",true);

      list.addItem("CMake",true);

      list.addItem("10.99$",false);

      list.addItem("Da-Crystal",true);

 

clip_image004

clip_image002

 

CMake & Qt4 Modules

Posted April 8th @ 5:04 pm by da-crystal

Don’t Reinvent the wheel!

After digging in CMake modules, and more specifically Qt once ( FindQ4.cmake , UseQt4.cmake also FindQT.cmake).  I found something really interesting in those modules!! They are smart modules ;) .  If you read my previous post CMake & Qt4 (Q3Support) and read this, you will see how stupid I was by “Reinventing the wheel” ;) .

 

Let get to the point!!

As we know ( I’m assuming you are familiar with Qt)  that Qt having many Modules e.g. ( Core, GUI ,Qt3Support,Network,SQL,XML,Test )  and lot other. And not necessarily that you need all of them in one project. It depends on the needs of your project.  Anyway, FindQt4 & UseQt4 come with very handy Macros to defined and include those modules with clean and cleaver way.

Basically you need three steps to instruct CMake about Qt.

First step tell CMake what Qt Modules you need. By setting Qt Modules’ variable to ‘true’. And the following are the available Qt Modules’ variable:

  • QT_USE_QT3SUPPORT
  • QT_USE_QTASSISTANT
  • QT_USE_QTDESIGNER
  • QT_USE_QTMOTIF
  • QT_USE_QTMAIN
  • QT_USE_QTNETWORK
  • QT_USE_QTNSPLUGIN
  • QT_USE_QTOPENGL
  • QT_USE_QTSQL
  • QT_USE_QTXML
  • QT_USE_QTSVG
  • QT_USE_QTTEST
  • QT_USE_QTUITOOLS
  • QT_USE_QTDBUS
  • QT_USE_QTSCRIPT

e.g.:

SET(QT_USE_QT3SUPPORT true)

Note that ‘Core’ and ‘GUI’ Modules libraries are loaded by default.  In case you don’t need to load them you can see the following variable as need to true:

  • QT_DONT_USE_QTCORE
  • QT_DONT_USE_QTGUI

 

Next step is to include the Qt need files. This done by only one statement:

INCLUDE(${QT_USE_FILE})

 

And the last step is the link the libraries need. This done by adding ‘${QT_LIBRARIES}’ to linking statement.

e.g.:

TARGET_LINK_LIBRARIES(CMakifyQt3S ${QT_LIBRARIES} )

 

Example:

If you recall CMakeLists.txt from”CMake & Qt4 (Q3Support) “:

# Qt Includes
    INCLUDE(${QT_USE_FILE})
    INCLUDE_DIRECTORIES(${QT_QT3SUPPORT_INCLUDE_DIR})

# Current Project Include
    INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
    INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})

# Generating UI’s
    FILE(GLOB Forms_UIS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UI/*.ui)
    QT4_WRAP_UI(Forms_UIS_H ${Forms_UIS})

# Sources files
    FILE(GLOB Sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)

# Qt Definitions
    ADD_DEFINITIONS(${QT_DEFINITIONS})
    ADD_DEFINITIONS(-DQT3_SUPPORT)

# Output
    SET(ALLSRC ${Sources} ${Forms_UIS_H})
    ADD_EXECUTABLE(CMakifyQt3S ${ALLSRC})
    TARGET_LINK_LIBRARIES(CMakifyQt3S
                  ${QT_LIBRARIES}
                  ${QT_QT3SUPPORT_LIBRARY}
     )

So after fully utilizing CMake Qt’ Modules, the CMakeLists.txt will be as follow:

# Qt Modules
    SET(QT_USE_QT3SUPPORT true)

# Qt Includes
    INCLUDE(${QT_USE_FILE})

# Current Project Include
    INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
    INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})

# Generating UI’s
    FILE(GLOB Forms_UIS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UI/*.ui)
    QT4_WRAP_UI(Forms_UIS_H ${Forms_UIS})

# Sources files
    FILE(GLOB Sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)

# Output
    SET(ALLSRC ${Sources} ${Forms_UIS_H})
    ADD_EXECUTABLE(CMakifyQt3S ${ALLSRC})
    TARGET_LINK_LIBRARIES(CMakifyQt3S ${QT_LIBRARIES})

Comments Off

CMake & Qt4 (Q3Support)

Posted April 3rd @ 11:45 pm by da-crystal

Updated: this post is obsolete, go to  CMake & Qt4  Modules .

 

Assumption:

Let assume we have a legacy Qt3 system and has been ported to Qt4 with Q3Support Module successfully. Also we want to CMakify it.

 

Problem:

After following the instructions that is available on the Internet like QtNode. We MIGHT end up with the following compilation errors:

* Error(1): ‘Q3somthing‘ : No such file or directory

    • ‘Q3MainWindow’: No such file or directory

* Error(2) :  ‘something‘ : is not a member of “Qt”

    • ‘ToolBarDock’ : is not a member of ‘Qt’
    • ‘Dock’ : is not a member of ‘Qt’

 

Solution:

in CMakeLists.txt

For Error(1) add the following :

# Qt Includes
    INCLUDE(${QT_USE_FILE})
    INCLUDE_DIRECTORIES(${QT_QT3SUPPORT_INCLUDE_DIR})

For Error(2) add the following:

# Qt Definitions
    ADD_DEFINITIONS(${QT_DEFINITIONS})
    ADD_DEFINITIONS(-DQT3_SUPPORT)

 

-DQT3_SUPPORT  almost two days to figure it out ending up with reading QT source-code.  So I hope this will help you.

 

Example:

I made example for this purpose also to show the simplicity and the power of CMake as cross-platform make system.

 

Windows Vista

Windows Vista & NMake(VS2008)

 

image

Linux & Make(gcc)

 

Example File: CMakifyQ3S

كتاب: ابدأ LINQ

Posted February 13th @ 9:31 am by da-crystal

Start_LINQ

خلال مروري عبر شبكة الانترنت وبالتحديد منتديات الفريق العربي للبرمجة ، وجدت موضوعاً اثار فضولي ( كتاب ” ابدأ Linq “… كتاب باللغة العربية ) .  لان LINQ  من الاضافات الجديد على .Net Framework 3 .

يحتوي الكتاب على ثلاثة فصول

  1. ميزات C#  وايضاً يشرح الميزات والتحسينات التي تم ادراجها في C# 3.
  2. أساسيات LINQ ، ويتكلم في هذا الفصل عن ماهية LINQ  واساسياتها.
  3. هذا الفصل يهتم بـ “Linq to SQL”

عدد صفحات الكتاب حوالي الخمسون (~50) صفحة ، ولاكنها كثيرة بالفائدة.  و للكتاب طريقة جدا مميزة في الشرح .

الكتاب متوفر بـصيغتين ( PDF و XPS )

image

فالدعاء لكتاب هذا الكتاب اقل ما يمكن فعله.

لتحميل الكتاب

  • Zip ( يحتوي على PDF و XPS )

Jawalnet -> The page cannot be found !

Posted December 9th @ 3:10 pm by da-crystal

sshot017

Sometime, if not mostly Angry, that annoying message appear for JawalNet users (like me Devil).

So if you are one of them, hope this post help you Embarrassed.

The cause of this problem are many e.g : 

  • Your proxy setting not setup correctly.
  • sometime JawalNet crappy DNS work at cache mode only ( don’t know how Confused, but that what I ended up of ).

 

So check you proxy setting first:

  • Http:   proxy.jawalnet.com.sa     Port: 8080
  • Socks: proxy.jawalnet.com.sa     Port: 1080

Then, If you still get that annoying message then it DNS problem.  the best way to solve this problem is by change DNS to one of the public DNS (free). 

    e.g OpenDNS ( one of the best if not the best ):

  • primary: 208.67.222.222
  • Secondary/Alt: 208.67.220.220

 

Step by Step ( for proxy setup ):

Comments Off

Qt/Windows & VC++ 2008 Express – Part1

Posted November 28th @ 9:40 pm by da-crystal

In this part I’ll show how to build Qt4 with MS Visual C++ 2008 (9.0) Express  ( yes, it out there Open-mouthed ) :

Requirement:

  1. MS Visual C++ 2008 (9.0) Express
  2. Qt/Windows Open Source Edition (.Zip version )

 

Steps:

  • decompress the file to folder of your choose let refer it as QtSource e.g:
    • C:\QtSource\

Update: From "Visual Studio 2008 Command Prompt":

  • now execute "configure.exe" , to prepare the source
    • C:\QtSource> configure
       

configure

  • now run ‘nmake" command , to compile the source ( it will take long time , 1 hour – 4 hours) :
    • C:\QtSource> nmake

Building 

  • At thing point, you have almost everything ready Open-mouthed ,  now have a fun playing with the the  demos  ( QtSource\bin\qtdemo.exe ):
    • C:\QtSource> cd bin
    • C:\QtSource> qtdemo

Demos

 

Environment Configuration:

Coin3D

Posted November 24th @ 10:42 pm by da-crystal

Coin3D is a cross-platform , a high-level, retained-mode toolkit for effective 3D graphics development. Also it’s offer a comprehensive and object-oriented 3D toolkit solution for interactive graphics programming problems. It based on Open Inventor. Coin3D develop by Kongsberg SIM-(Norwegian company).

It really have impressive scene database that make 3D programming more easier. That the part I love ;) . Also it come with lot of examples that that explain most of it features nicely and clearly.

So if you want to develop a 3D application (e.g. visualization ) with that can be easily port to many platform, then Coin3D is your choice. It support many platform also many GUI ( widgets ) system ( Qt , Windows, Mac OS X and Motif/X11 ). Also it have more features that I’ll highlight it later.

Now I’m using Coin3D with Qt4 to develop a visualization system that run under Linux/Windows.

 

 

Comments Off