Archive

Archive for the ‘C’ Category

Tizen Linux for mobile tablet smartphone will takeover the world. Backed by Intel, Samsung, Linux foundation. Good luck.

February 26, 2012 1 comment

Tizen Linux for mobile tablet smartphone will takeover the world. Backed by Intel, Samsung, Linux foundation. Good luck.

– Android is less important in such case

– IPhone also

 

Ubuntu now runs in Android. Finally C programmers are happy to have there GCC back in the mobile battle.

February 26, 2012 Leave a comment

Ubuntu is now running on top of Android. Soon there will be no more NDK/SDK requirement. Android made a mess mistake for GCC developers. Everything in past need to use NDK/SDK to retype every single lines to JNA code, which is idiot implementation actually of Android.

Android Ubuntu will then allow GCC

– Tizen linux from Intel, Samsung will soon release there dragon Linux with GCC support to take-over Android, IPhone

 

What is mobile? What is processor? What is mobile platform? What is ARM? How can i build mobile?

May 8, 2011 Leave a comment

Todo:

TuxPhone can be patched with Linux ARM kernel. Let me know if i should write some!

What is operating system? How can i build one? What do i need to build it?

May 8, 2011 Leave a comment

TODO:

Back to the past, it was like floppy disk where i wrote simple C/Pascal application to show my professor my project works. Now in modern generation, everything is like kick it and start it.

So, all we need is a collection of boot process to operating process bridge. That is done and doable with OpenSource operating systems out there.

Now to build your one, there is none because all the License terms and condition protect them to be copied and re-distribute

If it is interesting topic vote for it, for next episode.

 

Categories: C, centOS, Fedora 12, FreeBSD, Java, Solaris

Glade3 gtk c first simple application

December 11, 2010 Leave a comment

Start with very basic example:

Part 1: main.c

#include <gtk/gtk.h>

void on_window1_destroy (GtkObject       *object, gpointer         user_data)
{
gtk_main_quit();
}

void on_button2_clicked (GtkButton       *button,gpointer         user_data)
{
gtk_main_quit();
}

void on_button1_clicked (GtkButton       *button,gpointer         user_data)
{
printf(“Hello”);
}

int main( int    argc,
char **argv )
{
GtkBuilder *builder;
GtkWidget  *window;
GError     *error = NULL;

/* Init GTK+ */
gtk_init( &argc, &argv );

/* Create new GtkBuilder object */
builder = gtk_builder_new();
/* Load UI from file. If error occurs, report it and quit application.
* Replace “tut.glade” with your saved project. */
if( ! gtk_builder_add_from_file( builder, “window.glade”, &error ) )
{
g_warning( “%s”, error->message );
g_free( error );
return( 1 );
}

/* Get main window pointer from UI */
window = GTK_WIDGET( gtk_builder_get_object( builder, “window1” ) );

/* Connect signals */
gtk_builder_connect_signals( builder, NULL );

/* Destroy builder, since we don’t need it anymore */
g_object_unref( G_OBJECT( builder ) );

/* Show window. All other widgets are automatically shown by GtkBuilder */
gtk_widget_show( window );

/* Start main loop */
gtk_main();

return( 0 );
}

 

Part 2: prepared by Glade 3

<?xml version=”1.0″?>
<interface>
<requires lib=”gtk+” version=”2.14″/>
<!– interface-naming-policy project-wide –>
<object id=”window1″>
<signal name=”destroy” handler=”on_window1_destroy”/>
<child>
<object id=”vbox1″>
<property name=”visible”>True</property>
<property name=”orientation”>vertical</property>
<child>
<object id=”hbox1″>
<property name=”visible”>True</property>
<child>
<object id=”label1″>
<property name=”visible”>True</property>
<property name=”label” translatable=”yes”>label</property>
</object>
<packing>
<property name=”position”>0</property>
</packing>
</child>
<child>
<object id=”entry1″>
<property name=”visible”>True</property>
<property name=”can_focus”>True</property>
<property name=”invisible_char”>●</property>
</object>
<packing>
<property name=”position”>1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name=”position”>0</property>
</packing>
</child>
<child>
<object id=”button2″>
<property name=”label” translatable=”yes”>button</property>
<property name=”visible”>True</property>
<property name=”can_focus”>True</property>
<property name=”receives_default”>True</property>
</object>
<packing>
<property name=”position”>1</property>
</packing>
</child>
<child>
<object id=”button1″>
<property name=”label” translatable=”yes”>button</property>
<property name=”visible”>True</property>
<property name=”can_focus”>True</property>
<property name=”receives_default”>True</property>
<signal name=”clicked” handler=”on_button1_clicked”/>
</object>
<packing>
<property name=”position”>2</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

Part 3: compiled as gcc main.c -o main -Wall `pkg-config –cflags –libs gtk+-2.0 gmodule-2.0`

Categories: C

Gstreamer – to use for media

December 9, 2010 Leave a comment

#include <gst/gst.h>
#include <stdio.h>

int main (int argc, char *argv[])
{
/* Always initialize stuff. You’re never sure what value will the variable
* take! */

gchar *nano_str = NULL; /* No longer const otherwise you won’t be able to
* modify it. */
guint major = 0;
guint minor = 0;
guint micro = 0;
guint nano = 0;

gst_init (&argc, &argv);
gst_version (&major, &minor, &micro, &nano);
if (nano == 1)
nano_str = “(CVS)”;
else if (nano == 2)
nano_str = “(Prerelease)”;
else
nano_str = “”;

printf (“This program is linked against GStreamer %d.%d.%d %s\n”,
major, minor, micro, nano_str);
return 0;
}

[root@example CppApplication_1]# gcc main.c -o main -Wall `pkg-config –cflags –libs gstreamer-0.10`
[root@example CppApplication_1]# ls
build  dist  main  main.c  Makefile  nbproject
[root@example CppApplication_1]# ./main
This program is linked against GStreamer 0.10.29
[root@example CppApplication_1]#

 

 

Option 2:

[sun@example ~]$ cd /tmp

[sun@example tmp]$ gst-launch pulsesrc ! filesink location=dump.rawSetting pipeline to PAUSED …Pipeline is live and does not need PREROLL …Setting pipeline to PLAYING …New clock: GstAudioSrcClock
^CCaught interrupt — handling interrupt.Interrupt: Stopping pipeline …Execution ended after 40181185781 ns.Setting pipeline to PAUSED …Setting pipeline to READY …Setting pipeline to NULL …Freeing pipeline …

[sun@example tmp]$ gst-launch pulsesrc ! audioconvert ! vorbissenc ! oggmux ! filesink location=dump.ogg

WARNING: erroneous pipeline: no element “vorbissenc”

[sun@example tmp]$ gst-launch pulsesrc ! audioconvert ! vorbisenc ! oggmux ! filesink location=dump.oggSetting pipeline to PAUSED …Pipeline is live and does not need PREROLL …Setting pipeline to PLAYING …New clock: GstAudioSrcClock
^CCaught interrupt — handling interrupt.Interrupt: Stopping pipeline …Execution ended after 23210724917 ns.Setting pipeline to PAUSED …Setting pipeline to READY …Setting pipeline to NULL …Freeing pipeline …

[sun@example tmp]$

 

Categories: C

Skype – Getting started with C#

July 21, 2010 Leave a comment
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SKYPE4COMLib;

namespace SkypeBing
{
public partial class Form1 : Form
{
private Skype skype;
private const string trigger = "!"; // say help
private const string nick = "BOT";

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
skype = new Skype();
// use skype protocol 7
skype.Attach(7, false);
// listen
skype.MessageStatus += new _ISkypeEvents_MessageStatusEventHandler(skype_MessageStatus);
}

void skype_MessageStatus(ChatMessage pMessage, TChatMessageStatus Status)
{
// proceed only if the incoming message is a trigger
if (pMessage.Body.IndexOf(trigger) == 0)
{
// remove trigger string and make lower case
string command = pMessage.Body.Remove(0, trigger.Length).ToLower();

// send processed message back to skype chat window
skype.SendMessage(pMessage.Sender.Handle, nick +
" Says: " + ProcessCommand(command));
}
}

private string ProcessCommand(string str)
{
string result;
switch (str)
{
case "hello":
result = "Hello!";
break;
case "help":
result = "Sorry no help";
break;
default:
result = "default....";

break;

}

return result;
}
}
}
Categories: C