PDA

View Full Version : Plugin Source Code...



kanber_kav
04-09-2009, 08:41 AM
CCcaminfo 1.3 source code..
CCcaminfo.c


/*
* Nano-X GrGrabKey() demo program.
*
* Copyright(C) 2003 Jon Foster <jon@jon-foster.co.uk>
* Based on demo2.c
*
* This program allows the GrGrabKey() API to be tested.
* It creates a window, and displays key and hotkey events it recieves
* in that window. At startup it registers a key with GrGrabKey().
* The key and the registration type can both be specified on the
* command line.
*
* Usage:
* grabdemo key {n|h|x|s}
* Key is numerical MWKEY value (default 55='a').
* The second parameter is a single letter indicating the reservation
* type. Valid values:
* n - Normal (GR_GRAB_HOTKEY_EXCLUSIVE) (default)
* h - Hotkey (GR_GRAB_HOTKEY)
* x - eXclusive (GR_GRAB_EXCLUSIVE)
* m - Mouse (GR_GRAB_EXCLUSIVE_MOUSE)
*/

#define MWINCLUDECOLORS
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <nano-X.h>
#include <signal.h>
#include <string.h>
#include "nxcolors.h"
/*#include <time.h> //Zamanlayıcı için*/


static GR_WINDOW_ID main_window;
static GR_GC_ID main_gc;
static char message1[100] = "--- CCcam Info By AzDev ---Beta V1.3";
static char message3[100] = "Card Server Provid / Handler UpH/Mdwn Provid Name ";
char message2[110][300] ;

int kartim;
#define WIDTH 600
#define HEIGHT 500 //CİZİM ALANI BELİRLE
char server[2000][200];
char mevcut[2000][200];
char anahtar1[2000][9];
char anahtar2[2000][9];
int bulunans;
int bulunana1[2000];
int bulunanb1[2000];
static int Toplam;
int restat;

char caid[6];
char No[2000][7];
char servip[2000][50];
char card[4];
char at[4];
char hadler[7];
char handlerno[2000][9];
char uphops[6];
char uphopsno[2000][2];
char maxdown[8];
char maxdownno [2000][2];


static void draw_menu_key();
int k,adim;
/// Eklenti resim
#define FONTNAME "/MMP/hd/System/font/Font1.ttf"
#define FILE_IMAGE "/EMU/CCcaminfo/image" //azbox
//#define FILE_IMAGE "/root/workspace/azboxy/image" //pc
#ifndef FALSE
#define FALSE (0)
#endif

#ifndef TRUE
#define TRUE (!FALSE)
#endif
static GR_FONT_ID font;
static GR_IMAGE_ID PopupBox ;
static GR_IMAGE_ID s_iYellow ;
static GR_IMAGE_ID s_iBlue ;
static GR_IMAGE_ID s_pBgImage ;
static GR_IMAGE_ID s_Alt ;
static GR_IMAGE_ID s_Arka ;
#define ROW1_X 100
#define ROW1_Y 400
#define ROW1_H 15
///
static void ResimYukle(void)
{
s_pBgImage =GrLoadImageFromFile(FILE_IMAGE"/Background.png",FALSE);
s_iBlue =GrLoadImageFromFile(FILE_IMAGE"/iBlue.png",FALSE);
s_iYellow =GrLoadImageFromFile(FILE_IMAGE"/iYellow.png", FALSE);
PopupBox =GrLoadImageFromFile(FILE_IMAGE"/PopupBox.png", TRUE);
s_Alt =GrLoadImageFromFile(FILE_IMAGE"/Button.png", TRUE);
s_Arka =GrLoadImageFromFile(FILE_IMAGE"/MaxPopupBox.png", TRUE);

/*
s_pBgImage =GrLoadImageFromFile(FILE_IMAGE"/Background.jpg",FALSE);
s_iBlue =GrLoadImageFromFile(FILE_IMAGE"/iBlue.jpg",FALSE);
s_iYellow =GrLoadImageFromFile(FILE_IMAGE"/iYellow.jpg", FALSE);
PopupBox =GrLoadImageFromFile(FILE_IMAGE"/PopupBox.jpg", TRUE);
s_Alt =GrLoadImageFromFile(FILE_IMAGE"/Button.jpg", TRUE);
s_Arka =GrLoadImageFromFile(FILE_IMAGE"/MaxPopupBox.jpg", TRUE);
*/

}
static void ResimHafiza(void)
{
GrFreeImage(s_pBgImage);
GrFreeImage(s_iBlue);
GrFreeImage(s_iYellow);
GrFreeImage(PopupBox);
GrFreeImage(s_Alt);
GrFreeImage(s_Arka);
}

static void draw_menu_key()
{

font = GrCreateFont(FONTNAME, 15, NULL);
GrSetFontAttr(font, GR_TFANTIALIAS|GR_TFKERNING, 0);
GrSetGCFont(main_gc, font);
GrDrawImageToFit(main_window,main _gc,100,400 ,24,23,s_iBlue);
GrDrawImageToFit(main_window,main _gc,400,400 ,24,23,s_iYellow);

GrText(main_window, main_gc, 430 ,420, "Reset Emu", -1, GR_TFASCII);

GrText(main_window, main_gc, 130 ,420, "cccam.info Read", -1, GR_TFASCII);

GrDestroyFont(font);

}


typedef struct {

const char *name;
int mode;
// key translation pattern
// 0=DOWN/DOWN/.../UP
// 1=DOWN/DOWN/.../LONG/UP
// 2=DOWN/.../LONG/.../UP
// 3=.../LONG --> DOWN+UP or .../UP --> DOWN/UP
int count;
int key[2];
unsigned short mwkey;

}keys_map_td210;

#define MAX_KEY 60
keys_map_td210 keys_td210[MAX_KEY] = {
{ "MWKEY_ASCII_0", 0, 3, { 0, 4 }, '0'}, // 0 T0
{ "MWKEY_ASCII_1", 0, 3, { 1, 5 }, '1'}, // 1 T1
{ "MWKEY_ASCII_2", 0, 3, { 2, 6 }, '2'}, // 2 T2
{ "MWKEY_ASCII_3", 0, 3, { 3, 7 }, '3'}, // 3 T3
{ "MWKEY_ASCII_4", 0, 3, { 4, 8 }, '4'}, // 4 T4
{ "MWKEY_ASCII_5", 0, 3, { 5, 9 }, '5'}, // 5 T5
{ "MWKEY_ASCII_6", 0, 3, { 6, 10 }, '6'}, // 6 T6
{ "MWKEY_ASCII_7", 0, 3, { 7, 11 }, '7'}, // 7 T7
{ "MWKEY_ASCII_8", 0, 3, { 8, 12 }, '8'}, // 8 T8
{ "MWKEY_ASCII_9", 0, 3, { 9, 13 }, '9'}, // 9 T9
{ "MWKEY_CHANNEL_UP", 0, 3, { 10, 16 }, MWKEY_CHANNEL_UP}, // A CHUP
{ "MWKEY_CHANNEL_DOWN", 0, 3, { 11, 17 }, MWKEY_CHANNEL_DOWN}, // B CHDOWN
{ "Not Allowed", 0, 3, { 12, 18 }, 0}, // C VOLDOWN
{ "Not Allowed", 0, 3, { 13, 19 }, 0}, // D VOLUP
{ "Not Allowed", 2, 6, { 14, 20 }, 0}, // E MUTE
{ "MWKEY_UNKNOWN", 0, 3, { 15, 0 }, MWKEY_UNKNOWN}, // F NONE
{ "MWKEY_ENTER", 0, 3, { 16, 21 }, MWKEY_ENTER}, // 10 OK
{ "MWKEY_MENU", 0, 3, { 17, 22 }, MWKEY_MENU}, // 11 MENU
{ "MWKEY_UP", 0, 3, { 18, 23 }, MWKEY_UP}, // 12 UP
{ "MWKEY_DOWN", 0, 3, { 19, 24 }, MWKEY_DOWN}, // 13 DOWN
{ "MWKEY_LEFT", 0, 3, { 20, 25 }, MWKEY_LEFT}, // 14 LEFT
{ "MWKEY_RIGHT", 0, 3, { 21, 26 }, MWKEY_RIGHT}, // 15 RIGHT
{ "MWKEY_ESCAPE", 0, 3, { 22, 28 }, MWKEY_ESCAPE}, // 16 EXIT
{ "MWKEY_REWIND", 0, 3, { 23, 34 }, MWKEY_REWIND}, // 17 REW
{ "MWKEY_STOP", 0, 3, { 24, 35 }, MWKEY_STOP}, // 18 STOP
{ "MWKEY_PLAY", 0, 3, { 25, 36 }, MWKEY_PLAY}, // 19 PLAY
{ "MWKEY_FAST_FWD", 0, 3, { 26, 37 }, MWKEY_FAST_FWD}, // 1A FWD
{ "MWKEY_TRACK_PREV", 0, 3, { 27, 38 }, MWKEY_TRACK_PREV}, // 1B PREV
{ "MWKEY_TRACK_NEXT", 0, 3, { 28, 39 }, MWKEY_TRACK_NEXT}, // 1C NEXT
{ "MWKEY_RECORD", 0, 3, { 29, 40 }, MWKEY_RECORD}, // 1D RECORD
{ "MWKEY_BACKSPACE", 0, 3, { 30, 14 }, MWKEY_BACKSPACE}, // 1E DEL
{ "MWKEY_UNKNOWN", 0, 3, { 31, 0 }, MWKEY_UNKNOWN}, // 1F NONE
{ "MWKEY_CAPSLOCK", 0, 3, { 32, 15 }, MWKEY_CAPSLOCK}, // 20 CAPS
{ "MWKEY_COLORED_KEY_0", 0, 3, { 33, 58 }, MWKEY_COLORED_KEY_0}, // 21 RED
{ "MWKEY_COLORED_KEY_1", 0, 3, { 34, 59 }, MWKEY_COLORED_KEY_1}, // 22 GREEN
{ "MWKEY_COLORED_KEY_2", 0, 3, { 35, 60 }, MWKEY_COLORED_KEY_2}, // 23 YELLOW
{ "MWKEY_COLORED_KEY_3", 0, 3, { 36, 61 }, MWKEY_COLORED_KEY_3}, // 24 BLUE
{ "MWKEY_GUIDE", 0, 3, { 37, 41 }, MWKEY_GUIDE}, // 25 Guide
{ "MWKEY_F1", 0, 3, { 38, 30 }, MWKEY_F1}, // 26 CHECK
{ "Not Allowed", 0, 3, { 39, 56 }, 0}, // 27 RESOL
{ "MWKEY_INFO", 0, 3, { 40, 47 }, MWKEY_INFO}, // 28 INFO
{ "MWKEY_F2", 0, 3, { 41, 57 }, MWKEY_F2}, // 29 TVRADIO
{ "MWKEY_UNKNOWN", 2, 7, { 42, 1 }, MWKEY_UNKNOWN}, // 2A Power
{ "MWKEY_HOME", 2, 3, { 43, 46 }, MWKEY_HOME}, // 2B Home
{ "Not Allowed", 0, 3, { 44, 53 }, 0}, // 2C UHF
{ "Not Allowed", 0, 3, { 45, 54 }, 0}, // 2D AUX
{ "Not Allowed", 0, 3, { 46, 55 }, 0}, // 2E USB Eject
{ "MWKEY_F3", 0, 3, { 47, 29 }, MWKEY_F3}, // 2F Search
/* New Key */
{ "MWKEY_ESCAPE", 0, 3, { 48, 63 }, MWKEY_ESCAPE}, // 30 UTUBE
{ "MWKEY_ESCAPE", 0, 3, { 49, 64 }, MWKEY_ESCAPE}, // 31 WWW
{ "MWKEY_ESCAPE", 0, 3, { 50, 65 }, MWKEY_ESCAPE}, // 32 EMAIL
/* Front Key */
{ "MWKEY_UP", 0, 3, { 51, 44 }, MWKEY_UP}, // 33 ---UP
{ "MWKEY_DOWN", 0, 3, { 52, 45 }, MWKEY_DOWN}, // 34 ---DOWN
{ "MWKEY_LEFT", 3, 3, { 53, 42 }, MWKEY_LEFT}, // 35 ---LEFT
{ "MWKEY_RIGHT", 3, 3, { 54, 43 }, MWKEY_RIGHT}, // 36 ---RIGHT
{ "MWKEY_HOME", 0, 3, { 55, 46 }, MWKEY_HOME}, // 37 ---LAN(HOME)
//{ "K_LAN__", 0, 3, { 55, 62 }, }, // 37 ---LAN(HOME)
/* Virtual Key */
{ "MWKEY_ESCAPE", 0, 3, { 56, 49 }, MWKEY_ESCAPE}, // 38 SLEEP
{ "MWKEY_ESCAPE", 0, 3, { 57, 50 }, MWKEY_ESCAPE}, // 39 WAKEUP
{ "", 0, 3, { 58, 51 }, MWKEY_UNKNOWN}, // 40 VSLEEP
{ "", 0, 3, { 59, 52 }, MWKEY_UNKNOWN}, // 41 VWAKEUP
};

/* A counter - used so you can see the display being updated. */
static int getSerialNumber(void)
{
static int serial = 0;
if (++serial >= 1000)
serial = 0;
return serial;
}

/* If a character is ASCII, return it, else return a question mark. */
static char keyToChar(int key)
{
if ((key >= 32) && (key <= 127)) {
return (char)key;
} else {
return '?';
}
}

/* Makes a GrGrabKey() type paramater into a human-readable string */
static const char *grabKindName(int kind)
{
switch (kind) {
case GR_GRAB_HOTKEY_EXCLUSIVE:
return "GR_GRAB_HOTKEY_EXCLUSIVE";
case GR_GRAB_HOTKEY:
return "GR_GRAB_HOTKEY";
case GR_GRAB_EXCLUSIVE:
return "GR_GRAB_EXCLUSIVE";
case GR_GRAB_EXCLUSIVE_MOUSE:
return "GR_GRAB_EXCLUSIVE_MOUSE";
default:
return "Invalid GR_GRAB_ mode";
}
}

/* Repaint a specified area of the window */
int repaint(int x, int y, int width, int height)
{ //Sistem ekrana yazırılıyor

font = GrCreateFont(FONTNAME, 10, NULL);
GrSetFontAttr(font, GR_TFANTIALIAS|GR_TFKERNING, 0);
GrSetGCFont(main_gc, font);

GrSetGCForeground(main_gc, GR_RGB(145,139,90) );//Arka platform rengi
GrDrawImageToFit(main_window,main _gc,x,y ,WIDTH,360,s_Arka);
//GrFillRect(main_window, main_gc, x, y, width, 360);//içi boyalı dikdörtgen

GrSetGCUseBackground(main_gc, GR_FALSE); //DIGTORGEN ARKA PLANINI AL
GrSetGCForeground(main_gc, GR_RGB(58,165,188) );//Arka platform rengi

// GrFillRect(main_window, main_gc, 0, 380, width,60);//içi boyalı dikdörtgen



GrSetGCForeground(main_gc, GR_RGB(255,255,255)); //BUSEKİLDEDE YAZILABİLİR GrGetSysColor(GR_COLOR_APPTEXT) yazi rengi
GrText(main_window, main_gc, 150, 10, message1, -1, GR_TFASCII);

GrSetGCForeground(main_gc, GR_RGB(0,255,0));

font = GrCreateFont(FONTNAME, 15, NULL);

GrText(main_window, main_gc, 10, 30, message3, -1, GR_TFASCII);


font = GrCreateFont(FONTNAME, 10, NULL);
GrSetGCForeground(main_gc, GR_RGB(255,255,255));


int ktm;

adim=40;

for (k=0;k<Toplam;k++)
{ adim=adim+15;

GrText(main_window, main_gc, 10, adim, message2[k], -1, GR_TFASCII);

}

GrDrawImageToFit(main_window,main _gc,0,385 ,WIDTH - 10,50,s_Alt);

//GrRect(main_window, main_gc, 5, 5, WIDTH - 10, 355);
//GrRect(main_window, main_gc, 5,385, WIDTH - 10,50 );
draw_menu_key();
/*

if (restat==1)
{RestatCCcam();
}*/
}

/* Repaint the entire window */
static void repaintAll(void)
{
repaint(0,0,WIDTH,HEIGHT);
}



/*
* Bu plugini yazan
* DreamVDR
* Geliştirilmeye açık koddur.
*/


int DosyaOku()
{
FILE *fp1,*fp2,*fp3;
char birkelime;
char *c;
int a,t,f,b;




a=0;f=0;
fp1 = fopen("/tmp/cccam.info","r");

do {
// birkelime ='bos';
birkelime = fgetc(fp1);
if (birkelime != NULL);
if (birkelime =='\n' )
{birkelime='\n';
server[a][f-1]= '\0';//birkelime;
// server[a][f+1]= '\0';
// anahtar1[a][0]=server[a][f-9];
// anahtar1[a][1]=server[a][f-8];
// anahtar1[a][2]=server[a][f-7];
// anahtar1[a][3]=server[a][f-6];
// anahtar1[a][4]=server[a][f-5];
// anahtar1[a][5]=server[a][f-4];
// anahtar1[a][6]=server[a][f-3];
// anahtar1[a][7]=server[a][f-2];
// anahtar1[a][8]='\0';

int say,saym;
say=0;
saym=0;
int v;
v=0;
for(v=0;v<f;++v)
{ //printf("noooo--- %d----- %d \n",v,f);


if (server[a][v]==' ')
{
printf("say %d \n",say);
saym=0;
say=say+1;


} //anahtar
if (server[a][v]==' ') goto atla;


if (say==0)
{
caid[saym]=server[a][v];
saym=saym+1;
} //say


if (say==1)
{
No[a][saym]=server[a][v];
saym=saym+1;
} //say

if (say==2)
{
at[saym]=server[a][v];
saym=saym+1;
} //say

if (say==3)
{
servip[a][saym]=server[a][v];
saym=saym+1;
} //say


if (say==4)
{
card[saym]=server[a][v];
saym=saym+1;
} //say


if (say==5)
{
anahtar1[a][saym]=server[a][v];
saym=saym+1;
} //say


if (say==6)
{
hadler[saym]=server[a][v];
saym=saym+1;
} //say

if (say==7)
{
handlerno[a][saym]=server[a][v];
saym=saym+1;
} //say


if (say==8)
{
uphops[saym]=server[a][v];
saym=saym+1;
} //say


if (say==9)
{
uphopsno[a][saym]=server[a][v];
saym=saym+1;
} //say

if (say==10)
{
maxdown[saym]=server[a][v];
saym=saym+1;
} //say

if (say==11)
{
maxdownno[a][saym]=server[a][v];
saym=saym+1;
} //say
atla: "Bosluk";

} //for
// printf("no---%s %d \n",handlerno[0],say);

f=0;
a=a+1;
}
else
{server[a][f]= birkelime;

f=f+1;
}

} while (birkelime != '\377' ); /* Dosya sonu */
fclose(fp1);
f=0;
b=0;
sprintf( message1, "--- CCcam Info By AzDev ---Beta V1.3 ---> Online CARD=%d",a);

fp3 = fopen("CCcam.providers","r");
do {
// birkelime ='bos';
birkelime = fgetc(fp3);
if (birkelime != NULL);
if(birkelime =='\n' )
{birkelime='\n';
mevcut[b][f]= '\0';

anahtar2[b][0]=mevcut[b][0];
anahtar2[b][1]=mevcut[b][1];
anahtar2[b][2]=mevcut[b][2];
anahtar2[b][3]=mevcut[b][3];
anahtar2[b][4]=mevcut[b][4];
anahtar2[b][5]=mevcut[b][5];
anahtar2[b][6]=mevcut[b][6];
anahtar2[b][7]=mevcut[b][7];
anahtar2[b][8]='\0';


// printf("%s",mevcut[b]);
f=0;
b=b+1;
}
else
{mevcut[b][f]= birkelime;

f=f+1;
}

} while (birkelime != '\377' ); /* Dosya sonu */
fclose(fp3);


a=a-1;
t=0;
Bul (a,b);

}


int Bul(int a1,int b1)
{
bulunans=0;
int x,y,g;
g=0;
char *de1,*de2;
for (y=0;y<=a1;++y)
{g=0;
for (x=0;x<=b1;++x)
{
// strncpy(de1, anahtar1[y],7);
// strncpy(de2, anahtar1[x], 7);


int i;
i=0;

for(i=0;i<9;++i)
{
if (anahtar2[x][i]=='a') anahtar2[x][i]='A';
if (anahtar2[x][i]=='b') anahtar2[x][i]='B';
if (anahtar2[x][i]=='c') anahtar2[x][i]='C';
if (anahtar2[x][i]=='d') anahtar2[x][i]='D';
if (anahtar2[x][i]=='e') anahtar2[x][i]='E';
if (anahtar2[x][i]=='f') anahtar2[x][i]='F';
}

i=0;

for(i=0;i<9;++i)
{
if (anahtar1[x][i]=='a') anahtar1[x][i]='A';
if (anahtar1[x][i]=='b') anahtar1[x][i]='B';
if (anahtar1[x][i]=='c') anahtar1[x][i]='C';
if (anahtar1[x][i]=='d') anahtar1[x][i]='D';
if (anahtar1[x][i]=='e') anahtar1[x][i]='E';
if (anahtar1[x][i]=='f') anahtar1[x][i]='F';
}


de1=anahtar1[y];
de2=anahtar2[x];


// printf("---------%s---%s \n",de1,de2);


if (strcmp(de1,de2)==0) //iki sitring(po,nter karşılaştır)
{
bulunana1[bulunans]=y;
bulunanb1[bulunans]=x;
bulunans=bulunans+1;
// printf("%d---%d--%d \n",x,y,bulunans);
g=1;
break;
}//if

} //for x
if (g==0)
{
bulunana1[bulunans]=y;
bulunans=bulunans+1;
bulunanb1[bulunans]=0;
g=0;
}
} //for y

}

int Goster(int aralik2)
{int v,aralik,fg;
char *Stoplam;
char *diz1;
char *diz2;
fg=20;
Toplam=0;
v=0;
if (aralik2<0)
aralik2=0;

aralik=aralik2+fg;

if (aralik>bulunans)
{
aralik=bulunans;
}
for(v=aralik2;v<aralik;++v)
{

int ab,ba;
ba= bulunanb1[v];
ab= bulunana1[v];

// diz1=servip[ab];

diz2=mevcut[ba];


/*
char caid[6];
char No[1000][7];
char servip[1000][50];
char card[4];
char at[4];
char hadler[7];
char handlerno[1000][8];
char uphops[6];
char uphopsno[1000][2];
char maxdown[8];
char maxdownno [1000][2];
*/

sprintf( message2[Toplam],"%s %s %s / %s %s / %s --> %s ",No[ab],servip[ab],anahtar1[ab],handlerno[ab],uphopsno[ab],maxdownno[ab],diz2);


// sprintf( message2[Toplam],"%s %s %s/%s %s/%s --> %s ",No[ab],servip[ab],anahtar1[ab],handlerno[ab],uphopsno[ab],maxdownno[ab],diz2);
// printf("%s \n",message2[Toplam]);
Toplam=Toplam+1;


}

}







/*
do {

for (t=0;t<a;t++)
{
system("cp incubusCamdorg incubusCamd.conf");
system("killall -9 incubusCamd.sigma");
printf("%s",server[t]);
DosyaYAZ (server[t]);
system("cp incubusCamd.conf /EMU/OpenXCAS/incubusCamd/incubusCamd.conf");
system("cd /EMU/OpenXCAS/incubusCamd/ && ./incubusCamd.sigma &");
sleep(6);
}
t=0;
} while(1);
*/


int RestatCCcam()
{
system("killall -9 cccam_module &");
system("cd /EMU/OpenXCAS/CCcamCAS/ && ./cccam_module &");


font = GrCreateFont(FONTNAME, 15, NULL);
GrSetFontAttr(font, GR_TFANTIALIAS|GR_TFKERNING, 0);
GrSetGCFont(main_gc, font);
GrDrawImageToFit(main_window,main _gc,200,100 ,200,50,PopupBox);
GrText(main_window, main_gc, 250 ,125, "CCcam Restating...", -1, GR_TFASCII);
GrDestroyFont(font);

}


static void Resim_Init(void)
{
ResimYukle();
}



int
main(int argc,char **argv)
{
GR_EVENT event;
GR_WM_PROPERTIES props;
int grabResult;
int key = 'a';
int grabKind = GR_GRAB_HOTKEY_EXCLUSIVE;


DosyaOku();


//Ekranla bağlantı kur
if (GrOpen() < 0) {
printf("Can't open graphics\n");
exit(1);
}



/*
int delay;
delay=0;



do {

delay=delay+1;
if (delay>500) {restat=0;
repaintAll();
delay=0;
printf("deneme ... %d \n",delay);

}
} while (1);





*/








/* pass errors through main loop*/

GrSetErrorHandler(NULL);
Resim_Init();


main_window = GrNewWindow(GR_ROOT_WINDOW_ID, 20, 20, WIDTH, HEIGHT,
0, GREEN, RED);

props.flags = GR_WM_FLAGS_PROPS | GR_WM_FLAGS_TITLE;
props.props = GR_WM_PROPS_NOBACKGROUND;
props.title = "Nano-X GrabKey Demo";
GrSetWMProperties(main_window, &props);

main_gc = GrNewGC();


grabResult = GrGrabKey(main_window, key, grabKind);
//printf("%d\n", grabResult);

GrSelectEvents(main_window, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ
| GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP);
GrMapWindow(main_window);
GrSetFocus(main_window);
//GrDrawImageToFit(main_window,main _gc,0, 0,640,480,s_pBgImage); //Arkaplan ekrana yaz
//Basılan Tuşları bul
kartim=0;

for (;;) {

GrGetNextEvent(&event);
switch (event.type)
{
case GR_EVENT_TYPE_EXPOSURE:
repaint(event.exposure.x, event.exposure.y,
event.exposure.width, event.exposure.height);
break;
case GR_EVENT_TYPE_CLOSE_REQ:
GrClose();
exit(0);
break;
case GR_EVENT_TYPE_ERROR:
printf("\7grabdemo: Error (%s) ", event.error.name);
printf(nxErrorStrings[event.error.code],event.error.id);
break;
case GR_EVENT_TYPE_KEY_DOWN:
{
int i;
for(i=0;i<MAX_KEY;i++)
{
if(keys_td210[i].mwkey == event.keystroke.ch)
{

/* sprintf(message1, "%d uuu %03d Keyrrrr %d (%s) scan %d pressed \n",kartim,
getSerialNumber(), event.keystroke.ch,
keys_td210[i].name, event.keystroke.scancode);*/
if (keys_td210[i].name=="MWKEY_UP")
{//key up

kartim=kartim-1;

}

if (keys_td210[i].name=="MWKEY_DOWN")
{//keydown
kartim=kartim+1;

}

if (keys_td210[i].name=="MWKEY_LEFT")
{//key sol
kartim=kartim-10;

}

if (keys_td210[i].name=="MWKEY_RIGHT")
{//key sağ
kartim=kartim+10;

}

if (keys_td210[i].name=="MWKEY_COLORED_KEY_2")
{//key 0
restat=1;
RestatCCcam();
RestatCCcam();
sleep(5);
restat=0;
DosyaOku();
}

if (keys_td210[i].name=="MWKEY_COLORED_KEY_3")
{//key 0
kartim=0;
DosyaOku();
}





break;
}

}
}
if (kartim<0)
{ kartim=0;}font = GrCreateFont(FONTNAME, 15, NULL);
GrSetFontAttr(font, GR_TFANTIALIAS|GR_TFKERNING, 0);
GrSetGCFont(main_gc, font);

Goster(kartim);
repaintAll();
break;

}


}

//basılan tuşları bul son
ResimHafiza();
GrClose();
return 0;
}





Makefile source kode



.SUFFIXES:.c.o

CC = mipsel-linux-gcc

INC = ../include/microwin

LIBS = -L../lib -lnano-X

CFLAGS = -I$(INC)

OBJS = CCcaminfo.o

SRCS = CCcaminfo.c

TARGET = CCcaminfo.bin

all : $(TARGET)

$(TARGET) : $(OBJS)
$(CC) -o $@ $(OBJS) $(LIBS)

clean :
rm -rf $(OBJS) CCcaminfo/CCcaminfo CCcaminfo.plugin plugins.lst

install : $(TARGET)
mv CCcaminfo.bin CCcaminfo
mv CCcaminfo/CCcaminfo.bin CCcaminfo/CCcaminfo
tar -cvzf CCcaminfo.plugin CCcaminfo
echo CCcaminfo > plugins.lst

kanber_kav
04-09-2009, 08:44 AM
Mboxinfo source code
mboxinfo.c


/*
* Nano-X GrGrabKey() demo program.
*
* Copyright(C) 2003 Jon Foster <jon@jon-foster.co.uk>
* Based on demo2.c
*
* This program allows the GrGrabKey() API to be tested.
* It creates a window, and displays key and hotkey events it recieves
* in that window. At startup it registers a key with GrGrabKey().
* The key and the registration type can both be specified on the
* command line.
*
* Usage:
* grabdemo key {n|h|x|s}
* Key is numerical MWKEY value (default 55='a').
* The second parameter is a single letter indicating the reservation
* type. Valid values:
* n - Normal (GR_GRAB_HOTKEY_EXCLUSIVE) (default)
* h - Hotkey (GR_GRAB_HOTKEY)
* x - eXclusive (GR_GRAB_EXCLUSIVE)
* m - Mouse (GR_GRAB_EXCLUSIVE_MOUSE)
*/

#define MWINCLUDECOLORS
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <nano-X.h>
#include <signal.h>
#include <string.h>
#include "nxcolors.h"
/*#include <time.h> //Zamanlayıcı için*/


static GR_WINDOW_ID main_window;
static GR_GC_ID main_gc;
static char message1[100] = "--- MBox Card Info By KKav ---Beta V1.0";
char message2[100][300] ;

int kartim;
#define WIDTH 600
#define HEIGHT 500 //CİZİM ALANI BELİRLE
char server[1000][200];
char mevcut[1000][200];
char anahtar1[1000][9];
char anahtar2[1000][9];
int bulunans,okunan;
int bulunana1[1000];
int bulunanb1[1000];
static int Toplam,Toplam2;
static int restat,Goruntu;
static void draw_menu_key();
int k,adim;
/// Eklenti resim
#define FONTNAME "/MMP/hd/System/font/Font1.ttf"
#define FILE_IMAGE "/EMU/mboxinfo/image"
#ifndef FALSE
#define FALSE (0)
#endif

#ifndef TRUE
#define TRUE (!FALSE)
#endif
static GR_FONT_ID font;
static GR_IMAGE_ID PopupBox ;
static GR_IMAGE_ID s_iYellow ;
static GR_IMAGE_ID s_iBlue ;
static GR_IMAGE_ID s_iGreen ;
static GR_IMAGE_ID s_pBgImage ;
static GR_IMAGE_ID s_Alt ;
static GR_IMAGE_ID s_Arka ;
#define ROW1_X 100
#define ROW1_Y 400
#define ROW1_H 15
///
static void ResimYukle(void)
{
/*s_pBgImage =GrLoadImageFromFile(FILE_IMAGE"/Background.jpg",FALSE);
s_iBlue =GrLoadImageFromFile(FILE_IMAGE"/iBlue.jpg",FALSE);
s_iYellow =GrLoadImageFromFile(FILE_IMAGE"/iYellow.jpg", FALSE);
s_iGreen=GrLoadImageFromFile(FILE _IMAGE"/iGreen.jpg", FALSE);
PopupBox =GrLoadImageFromFile(FILE_IMAGE"/PopupBox.jpg", TRUE);
s_Alt =GrLoadImageFromFile(FILE_IMAGE"/Button.jpg", TRUE);
s_Arka =GrLoadImageFromFile(FILE_IMAGE"/MaxPopupBox.jpg", TRUE);

*/
s_pBgImage =GrLoadImageFromFile(FILE_IMAGE"/Background.png",FALSE);
s_iBlue =GrLoadImageFromFile(FILE_IMAGE"/iBlue.png",FALSE);
s_iYellow =GrLoadImageFromFile(FILE_IMAGE"/iYellow.png", FALSE);
s_iGreen=GrLoadImageFromFile(FILE _IMAGE"/iGreen.png", FALSE);
PopupBox =GrLoadImageFromFile(FILE_IMAGE"/PopupBox.png", TRUE);
s_Alt =GrLoadImageFromFile(FILE_IMAGE"/Button.png", TRUE);
s_Arka =GrLoadImageFromFile(FILE_IMAGE"/MaxPopupBox.png", TRUE);




}
static void ResimHafiza(void)
{
GrFreeImage(s_pBgImage);
GrFreeImage(s_iBlue);
GrFreeImage(s_iYellow);
GrFreeImage(PopupBox);
GrFreeImage(s_Alt);
GrFreeImage(s_Arka);
GrFreeImage(s_iGreen);
}

static void draw_menu_key()
{

font = GrCreateFont(FONTNAME, 15, NULL);
GrSetFontAttr(font, GR_TFANTIALIAS|GR_TFKERNING, 0);
GrSetGCFont(main_gc, font);
GrDrawImageToFit(main_window,main _gc,100,400 ,24,23,s_iBlue);
GrDrawImageToFit(main_window,main _gc,250,400 ,24,23,s_iGreen);
GrDrawImageToFit(main_window,main _gc,400,400 ,24,23,s_iYellow);

GrText(main_window, main_gc, 430 ,420, "Reset Emu", -1, GR_TFASCII);
GrText(main_window, main_gc, 280 ,420, "Peer Read", -1, GR_TFASCII);
GrText(main_window, main_gc, 130 ,420, "share.info Read", -1, GR_TFASCII);

GrDestroyFont(font);

}


typedef struct {

const char *name;
int mode;
// key translation pattern
// 0=DOWN/DOWN/.../UP
// 1=DOWN/DOWN/.../LONG/UP
// 2=DOWN/.../LONG/.../UP
// 3=.../LONG --> DOWN+UP or .../UP --> DOWN/UP
int count;
int key[2];
unsigned short mwkey;

}keys_map_td210;

#define MAX_KEY 60
keys_map_td210 keys_td210[MAX_KEY] = {
{ "MWKEY_ASCII_0", 0, 3, { 0, 4 }, '0'}, // 0 T0
{ "MWKEY_ASCII_1", 0, 3, { 1, 5 }, '1'}, // 1 T1
{ "MWKEY_ASCII_2", 0, 3, { 2, 6 }, '2'}, // 2 T2
{ "MWKEY_ASCII_3", 0, 3, { 3, 7 }, '3'}, // 3 T3
{ "MWKEY_ASCII_4", 0, 3, { 4, 8 }, '4'}, // 4 T4
{ "MWKEY_ASCII_5", 0, 3, { 5, 9 }, '5'}, // 5 T5
{ "MWKEY_ASCII_6", 0, 3, { 6, 10 }, '6'}, // 6 T6
{ "MWKEY_ASCII_7", 0, 3, { 7, 11 }, '7'}, // 7 T7
{ "MWKEY_ASCII_8", 0, 3, { 8, 12 }, '8'}, // 8 T8
{ "MWKEY_ASCII_9", 0, 3, { 9, 13 }, '9'}, // 9 T9
{ "MWKEY_CHANNEL_UP", 0, 3, { 10, 16 }, MWKEY_CHANNEL_UP}, // A CHUP
{ "MWKEY_CHANNEL_DOWN", 0, 3, { 11, 17 }, MWKEY_CHANNEL_DOWN}, // B CHDOWN
{ "Not Allowed", 0, 3, { 12, 18 }, 0}, // C VOLDOWN
{ "Not Allowed", 0, 3, { 13, 19 }, 0}, // D VOLUP
{ "Not Allowed", 2, 6, { 14, 20 }, 0}, // E MUTE
{ "MWKEY_UNKNOWN", 0, 3, { 15, 0 }, MWKEY_UNKNOWN}, // F NONE
{ "MWKEY_ENTER", 0, 3, { 16, 21 }, MWKEY_ENTER}, // 10 OK
{ "MWKEY_MENU", 0, 3, { 17, 22 }, MWKEY_MENU}, // 11 MENU
{ "MWKEY_UP", 0, 3, { 18, 23 }, MWKEY_UP}, // 12 UP
{ "MWKEY_DOWN", 0, 3, { 19, 24 }, MWKEY_DOWN}, // 13 DOWN
{ "MWKEY_LEFT", 0, 3, { 20, 25 }, MWKEY_LEFT}, // 14 LEFT
{ "MWKEY_RIGHT", 0, 3, { 21, 26 }, MWKEY_RIGHT}, // 15 RIGHT
{ "MWKEY_ESCAPE", 0, 3, { 22, 28 }, MWKEY_ESCAPE}, // 16 EXIT
{ "MWKEY_REWIND", 0, 3, { 23, 34 }, MWKEY_REWIND}, // 17 REW
{ "MWKEY_STOP", 0, 3, { 24, 35 }, MWKEY_STOP}, // 18 STOP
{ "MWKEY_PLAY", 0, 3, { 25, 36 }, MWKEY_PLAY}, // 19 PLAY
{ "MWKEY_FAST_FWD", 0, 3, { 26, 37 }, MWKEY_FAST_FWD}, // 1A FWD
{ "MWKEY_TRACK_PREV", 0, 3, { 27, 38 }, MWKEY_TRACK_PREV}, // 1B PREV
{ "MWKEY_TRACK_NEXT", 0, 3, { 28, 39 }, MWKEY_TRACK_NEXT}, // 1C NEXT
{ "MWKEY_RECORD", 0, 3, { 29, 40 }, MWKEY_RECORD}, // 1D RECORD
{ "MWKEY_BACKSPACE", 0, 3, { 30, 14 }, MWKEY_BACKSPACE}, // 1E DEL
{ "MWKEY_UNKNOWN", 0, 3, { 31, 0 }, MWKEY_UNKNOWN}, // 1F NONE
{ "MWKEY_CAPSLOCK", 0, 3, { 32, 15 }, MWKEY_CAPSLOCK}, // 20 CAPS
{ "MWKEY_COLORED_KEY_0", 0, 3, { 33, 58 }, MWKEY_COLORED_KEY_0}, // 21 RED
{ "MWKEY_COLORED_KEY_1", 0, 3, { 34, 59 }, MWKEY_COLORED_KEY_1}, // 22 GREEN
{ "MWKEY_COLORED_KEY_2", 0, 3, { 35, 60 }, MWKEY_COLORED_KEY_2}, // 23 YELLOW
{ "MWKEY_COLORED_KEY_3", 0, 3, { 36, 61 }, MWKEY_COLORED_KEY_3}, // 24 BLUE
{ "MWKEY_GUIDE", 0, 3, { 37, 41 }, MWKEY_GUIDE}, // 25 Guide
{ "MWKEY_F1", 0, 3, { 38, 30 }, MWKEY_F1}, // 26 CHECK
{ "Not Allowed", 0, 3, { 39, 56 }, 0}, // 27 RESOL
{ "MWKEY_INFO", 0, 3, { 40, 47 }, MWKEY_INFO}, // 28 INFO
{ "MWKEY_F2", 0, 3, { 41, 57 }, MWKEY_F2}, // 29 TVRADIO
{ "MWKEY_UNKNOWN", 2, 7, { 42, 1 }, MWKEY_UNKNOWN}, // 2A Power
{ "MWKEY_HOME", 2, 3, { 43, 46 }, MWKEY_HOME}, // 2B Home
{ "Not Allowed", 0, 3, { 44, 53 }, 0}, // 2C UHF
{ "Not Allowed", 0, 3, { 45, 54 }, 0}, // 2D AUX
{ "Not Allowed", 0, 3, { 46, 55 }, 0}, // 2E USB Eject
{ "MWKEY_F3", 0, 3, { 47, 29 }, MWKEY_F3}, // 2F Search
/* New Key */
{ "MWKEY_ESCAPE", 0, 3, { 48, 63 }, MWKEY_ESCAPE}, // 30 UTUBE
{ "MWKEY_ESCAPE", 0, 3, { 49, 64 }, MWKEY_ESCAPE}, // 31 WWW
{ "MWKEY_ESCAPE", 0, 3, { 50, 65 }, MWKEY_ESCAPE}, // 32 EMAIL
/* Front Key */
{ "MWKEY_UP", 0, 3, { 51, 44 }, MWKEY_UP}, // 33 ---UP
{ "MWKEY_DOWN", 0, 3, { 52, 45 }, MWKEY_DOWN}, // 34 ---DOWN
{ "MWKEY_LEFT", 3, 3, { 53, 42 }, MWKEY_LEFT}, // 35 ---LEFT
{ "MWKEY_RIGHT", 3, 3, { 54, 43 }, MWKEY_RIGHT}, // 36 ---RIGHT
{ "MWKEY_HOME", 0, 3, { 55, 46 }, MWKEY_HOME}, // 37 ---LAN(HOME)
//{ "K_LAN__", 0, 3, { 55, 62 }, }, // 37 ---LAN(HOME)
/* Virtual Key */
{ "MWKEY_ESCAPE", 0, 3, { 56, 49 }, MWKEY_ESCAPE}, // 38 SLEEP
{ "MWKEY_ESCAPE", 0, 3, { 57, 50 }, MWKEY_ESCAPE}, // 39 WAKEUP
{ "", 0, 3, { 58, 51 }, MWKEY_UNKNOWN}, // 40 VSLEEP
{ "", 0, 3, { 59, 52 }, MWKEY_UNKNOWN}, // 41 VWAKEUP
};

/* A counter - used so you can see the display being updated. */
static int getSerialNumber(void)
{
static int serial = 0;
if (++serial >= 1000)
serial = 0;
return serial;
}

/* If a character is ASCII, return it, else return a question mark. */
static char keyToChar(int key)
{
if ((key >= 32) && (key <= 127)) {
return (char)key;
} else {
return '?';
}
}

/* Makes a GrGrabKey() type paramater into a human-readable string */
static const char *grabKindName(int kind)
{
switch (kind) {
case GR_GRAB_HOTKEY_EXCLUSIVE:
return "GR_GRAB_HOTKEY_EXCLUSIVE";
case GR_GRAB_HOTKEY:
return "GR_GRAB_HOTKEY";
case GR_GRAB_EXCLUSIVE:
return "GR_GRAB_EXCLUSIVE";
case GR_GRAB_EXCLUSIVE_MOUSE:
return "GR_GRAB_EXCLUSIVE_MOUSE";
default:
return "Invalid GR_GRAB_ mode";
}
}

/* Repaint a specified area of the window */
int repaint(int x, int y, int width, int height)
{ //Sistem ekrana yazırılıyor

font = GrCreateFont(FONTNAME, 10, NULL);
GrSetFontAttr(font, GR_TFANTIALIAS|GR_TFKERNING, 0);
GrSetGCFont(main_gc, font);

GrSetGCForeground(main_gc, GR_RGB(145,139,90) );//Arka platform rengi
GrDrawImageToFit(main_window,main _gc,x,y ,WIDTH,360,s_Arka);
//GrFillRect(main_window, main_gc, x, y, width, 360);//içi boyalı dikdörtgen

GrSetGCUseBackground(main_gc, GR_FALSE); //DIGTORGEN ARKA PLANINI AL
GrSetGCForeground(main_gc, GR_RGB(58,165,188) );//Arka platform rengi

// GrFillRect(main_window, main_gc, 0, 380, width,60);//içi boyalı dikdörtgen



GrSetGCForeground(main_gc, GR_RGB(255,255,255)); //BUSEKİLDEDE YAZILABİLİR GrGetSysColor(GR_COLOR_APPTEXT) yazi rengi
GrText(main_window, main_gc, 150, 20, message1, -1, GR_TFASCII);
int ktm;

adim=30;

for (k=0;k<Toplam;k++)
{ adim=adim+15;

GrText(main_window, main_gc, 10, adim, message2[k], -1, GR_TFASCII);

}

GrDrawImageToFit(main_window,main _gc,0,385 ,WIDTH - 10,50,s_Alt);

//GrRect(main_window, main_gc, 5, 5, WIDTH - 10, 355);
//GrRect(main_window, main_gc, 5,385, WIDTH - 10,50 );
draw_menu_key();
/*

if (restat==1)
{RestatCCcam();
}*/
}

/* Repaint the entire window */
static void repaintAll(void)
{
repaint(0,0,WIDTH,HEIGHT);
}



/*
* Bu plugini yazan
* DreamVDR
* Geliştirilmeye açık koddur.
*/


int DosyaOku()
{Goruntu=0;
FILE *fp1,*fp2,*fp3;
char birkelime;
char *c;
int a,t,f,b;



a=0;f=0;
fp1 = fopen("/tmp/share.info","r");


do {
// birkelime ='bos';
birkelime = fgetc(fp1);
if (birkelime != NULL);
if (birkelime =='\n' )
{birkelime='\n';
server[a][f-1]= '\0';//birkelime;
// server[a][f+1]= '\0';
anahtar1[a][0]=server[a][f-35];
anahtar1[a][1]=server[a][f-34];
anahtar1[a][2]=server[a][f-33];
anahtar1[a][3]=server[a][f-32];
anahtar1[a][4]=server[a][f-31];
anahtar1[a][5]=server[a][f-30];
anahtar1[a][6]=server[a][f-29];
anahtar1[a][7]=server[a][f-28];
anahtar1[a][8]='\0';
// printf("%s",server[a]);
f=0;
a=a+1;
}
else
{server[a][f]= birkelime;

f=f+1;
}

} while (birkelime != '\377' ); /* Dosya sonu */
fclose(fp1);
f=0;
b=0;
sprintf( message1, "--- MBox Card Info By KKav ---Beta V1.0 Online CARD=%d",a);

fp3 = fopen("ident.info","r");
do {
// birkelime ='bos';
birkelime = fgetc(fp3);
if (birkelime != NULL);
if(birkelime =='\n' )
{birkelime='\n';
mevcut[b][f]= '\0';

anahtar2[b][0]=mevcut[b][0];
anahtar2[b][1]=mevcut[b][1];
anahtar2[b][2]=mevcut[b][2];
anahtar2[b][3]=mevcut[b][3];
anahtar2[b][4]=mevcut[b][4];
anahtar2[b][5]=mevcut[b][5];
anahtar2[b][6]=mevcut[b][6];
anahtar2[b][7]=mevcut[b][7];
anahtar2[b][8]='\0';


// printf("%s",mevcut[b]);
f=0;
b=b+1;
}
else
{mevcut[b][f]= birkelime;

f=f+1;
}

} while (birkelime != '\377' ); /* Dosya sonu */
fclose(fp3);


a=a-1;
t=0;
Bul (a,b);

}


int Bul(int a1,int b1)
{
bulunans=0;
int x,y,g;
g=0;
char *de1,*de2;
for (y=0;y<=a1;++y)
{g=0;
for (x=0;x<=b1;++x)
{
// strncpy(de1, anahtar1[y],7);
// strncpy(de2, anahtar1[x], 7);


int i;
i=0;

for(i=0;i<9;++i)
{
if (anahtar2[x][i]=='a') anahtar2[x][i]='A';
if (anahtar2[x][i]=='b') anahtar2[x][i]='B';
if (anahtar2[x][i]=='c') anahtar2[x][i]='C';
if (anahtar2[x][i]=='d') anahtar2[x][i]='D';
if (anahtar2[x][i]=='e') anahtar2[x][i]='E';
if (anahtar2[x][i]=='f') anahtar2[x][i]='F';
}

i=0;

for(i=0;i<9;++i)
{
if (anahtar1[x][i]=='a') anahtar1[x][i]='A';
if (anahtar1[x][i]=='b') anahtar1[x][i]='B';
if (anahtar1[x][i]=='c') anahtar1[x][i]='C';
if (anahtar1[x][i]=='d') anahtar1[x][i]='D';
if (anahtar1[x][i]=='e') anahtar1[x][i]='E';
if (anahtar1[x][i]=='f') anahtar1[x][i]='F';
}


de1=anahtar1[y];
de2=anahtar2[x];


//printf("---------%s <---> %s \n",de1,de2);


if (strcmp(de1,de2)==0) //iki sitring(po,nter karşılaştır)
{
bulunana1[bulunans]=y;
bulunanb1[bulunans]=x;
bulunans=bulunans+1;
// printf("%d---%d--%d \n",x,y,bulunans);
g=1;
break;
}//if

} //for x
if (g==0)
{
bulunana1[bulunans]=y;
bulunans=bulunans+1;
bulunanb1[bulunans]=0;
g=0;
}
} //for y

}

int Goster(int aralik2)
{int v,aralik,fg;
char *Stoplam;
char *diz1;
char *diz2;
fg=20;
Toplam=0;
v=0;
if (aralik2<0)
aralik2=0;

aralik=aralik2+fg;

if (aralik>bulunans)
{
aralik=bulunans;
}
for(v=aralik2;v<aralik;++v)
{

int ab,ba;
ba= bulunanb1[v];
ab= bulunana1[v];

diz1=server[ab];
diz2=mevcut[ba];
sprintf( message2[Toplam],"%s --> %s ",diz1,diz2);
//printf("%s \n",message2[Toplam]);
Toplam=Toplam+1;


}

}



int RestatCCcam()
{
system("killall -9 mbox_module &");
system("cd /EMU/OpenXCAS/MboxCAS/ && ./mbox.sh &");


font = GrCreateFont(FONTNAME, 15, NULL);
GrSetFontAttr(font, GR_TFANTIALIAS|GR_TFKERNING, 0);
GrSetGCFont(main_gc, font);
GrDrawImageToFit(main_window,main _gc,200,100 ,200,50,PopupBox);
GrText(main_window, main_gc, 250 ,125, "MBox Restating...", -1, GR_TFASCII);
GrDestroyFont(font);

}


static void Resim_Init(void)
{
ResimYukle();
}



int
main(int argc,char **argv)
{
GR_EVENT event;
GR_WM_PROPERTIES props;
int grabResult;
int key = 'a';
int grabKind = GR_GRAB_HOTKEY_EXCLUSIVE;


DosyaOku();


//Ekranla bağlantı kur
if (GrOpen() < 0) {
printf("Can't open graphics\n");
exit(1);
}
/* pass errors through main loop*/

GrSetErrorHandler(NULL);
Resim_Init();


main_window = GrNewWindow(GR_ROOT_WINDOW_ID, 20, 20, WIDTH, HEIGHT,
0, GREEN, RED);

props.flags = GR_WM_FLAGS_PROPS | GR_WM_FLAGS_TITLE;
props.props = GR_WM_PROPS_NOBACKGROUND;
props.title = "Nano-X GrabKey Demo";
GrSetWMProperties(main_window, &props);

main_gc = GrNewGC();


grabResult = GrGrabKey(main_window, key, grabKind);
//printf("%d\n", grabResult);

GrSelectEvents(main_window, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ
| GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP);
GrMapWindow(main_window);
GrSetFocus(main_window);
//GrDrawImageToFit(main_window,main _gc,0, 0,640,480,s_pBgImage); //Arkaplan ekrana yaz
//Basılan Tuşları bul
kartim=0;

for (;;) {

GrGetNextEvent(&event);
switch (event.type)
{
case GR_EVENT_TYPE_EXPOSURE:
repaint(event.exposure.x, event.exposure.y,
event.exposure.width, event.exposure.height);
break;
case GR_EVENT_TYPE_CLOSE_REQ:
GrClose();
exit(0);
break;
case GR_EVENT_TYPE_ERROR:
printf("\7grabdemo: Error (%s) ", event.error.name);
printf(nxErrorStrings[event.error.code],event.error.id);
break;
case GR_EVENT_TYPE_KEY_DOWN:
{
int i;
for(i=0;i<MAX_KEY;i++)
{
if(keys_td210[i].mwkey == event.keystroke.ch)
{

/* sprintf(message1, "%d uuu %03d Keyrrrr %d (%s) scan %d pressed \n",kartim,
getSerialNumber(), event.keystroke.ch,
keys_td210[i].name, event.keystroke.scancode);*/
if (keys_td210[i].name=="MWKEY_UP")
{//key up

kartim=kartim-1;

}

if (keys_td210[i].name=="MWKEY_DOWN")
{//keydown
kartim=kartim+1;

}

if (keys_td210[i].name=="MWKEY_LEFT")
{//key sol
kartim=kartim-10;

}

if (keys_td210[i].name=="MWKEY_RIGHT")
{//key sağ
kartim=kartim+10;

}

if (keys_td210[i].name=="MWKEY_COLORED_KEY_2")
{//key 0
restat=1;
RestatCCcam();
RestatCCcam();
sleep(5);
restat=0;
DosyaOku();
}

if (keys_td210[i].name=="MWKEY_COLORED_KEY_3")
{//key 0
kartim=0;
Goruntu=0;
DosyaOku();

}

if (keys_td210[i].name=="MWKEY_COLORED_KEY_1")
{//key 0
Goruntu=1;
kartim=0;
DosyaOku2();

}




break;
}

}
}
if (kartim<0)
{ kartim=0;}
font = GrCreateFont(FONTNAME, 15, NULL);
GrSetFontAttr(font, GR_TFANTIALIAS|GR_TFKERNING, 0);
GrSetGCFont(main_gc, font);
//printf("%d %d \n",Goruntu,kartim);
if (Goruntu==0) Goster(kartim);
if (Goruntu==1) Goster2(kartim);
repaintAll();
break;

}


}

//basılan tuşları bul son
ResimHafiza();
GrClose();
return 0;
}



/* Zamanlayıcı

void bastir(double delaySec,int count)
{
while (count--)
{
clock_t tBegin;
tBegin = clock();
RestatCCcam();
while ((double)(clock() - tBegin) / CLOCKS_PER_SEC <= delaySec)
;
}
}

*/






int DosyaOku2()
{Goruntu=1;
FILE *fp1,*fp2,*fp3;
char birkelime;
char *c;
int a,t,f,b;



a=0;f=0;
fp1 = fopen("/tmp/share.onl","r");


do {
// birkelime ='bos';
birkelime = fgetc(fp1);
if (birkelime != NULL);
if (birkelime =='\n' )
{birkelime='\n';
server[a][f-1]= '\0';//birkelime;

// printf("%s \n",server[a]);
f=0;
a=a+1;


}
else
{server[a][f]= birkelime;

f=f+1;
}

} while (birkelime != '\377' ); /* Dosya sonu */
fclose(fp1);

Toplam2=a;

sprintf( message1, "--- MBox Card Info By KKav ---Beta V1.0 Peer=%d",Toplam2);
}



int Goster2(int aralik2)
{int v,aralik,fg;
char *Stoplam;
char *diz1;
char *diz2;
fg=20;

Toplam=0;
v=0;
if (aralik2<0)
aralik2=0;

aralik=aralik2+fg;

if (aralik>Toplam2)
{
aralik=Toplam2;
}

//printf("aralik=%d %d \n",aralik,aralik2);

for(v=aralik2;v<aralik;++v)
{

diz1=server[v];
// printf("fffffffff %s \n",diz1);

sprintf( message2[Toplam],"%s ",diz1);
printf("%s \n",message2[Toplam]);
Toplam=Toplam+1;
}
}






Makefile Code


.SUFFIXES:.c.o

CC = mipsel-linux-gcc

INC = ../include/microwin

LIBS = -L../lib -lnano-X

CFLAGS = -I$(INC)

OBJS = mboxinfo.o

SRCS = mboxinfo.c

TARGET = mboxinfo.bin

all : $(TARGET)

$(TARGET) : $(OBJS)
$(CC) -o $@ $(OBJS) $(LIBS)

clean :
rm -rf $(OBJS) mboxinfo/mboxinfo mboxinfo.plugin plugins.lst

install : $(TARGET)
mv mboxinfo.bin mboxinfo
mv mboxinfo/mboxinfo.bin mboxinfo/mboxinfo
tar -cvzf mboxinfo.plugin mboxinfo
echo mboxinfo > plugins.lst

kanber_kav
04-09-2009, 08:47 AM
Google 1.1 source code...



/*
* Nano-X GrGrabKey() demo program.
*
* Copyright(C) 2003 Jon Foster <jon@jon-foster.co.uk>
* Based on demo2.c
*
* This program allows the GrGrabKey() API to be tested.
* It creates a window, and displays key and hotkey events it recieves
* in that window. At startup it registers a key with GrGrabKey().
* The key and the registration type can both be specified on the
* command line.
*
* Usage:
* grabdemo key {n|h|x|s}
* Key is numerical MWKEY value (default 55='a').
* The second parameter is a single letter indicating the reservation
* type. Valid values:
* n - Normal (GR_GRAB_HOTKEY_EXCLUSIVE) (default)
* h - Hotkey (GR_GRAB_HOTKEY)
* x - eXclusive (GR_GRAB_EXCLUSIVE)
* m - Mouse (GR_GRAB_EXCLUSIVE_MOUSE)
*/

#define MWINCLUDECOLORS
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include </root/microwin/src/include/nano-X.h>
#include <signal.h>
#include <string.h>
#include <stdio.h>
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>

/*#include <time.h> //Zamanlayıcı için*/


static GR_WINDOW_ID main_window;
static GR_GC_ID main_gc;
static char message1[100] = "--- Google Map --- Beta V1.1 By AzDev";
//char message2[100][300] ;

int kartim;
#define WIDTH 640
#define HEIGHT 480 //CİZİM ALANI BELİRLE



//char server[1000][200];
//int uzunluk[1000];
//char Baslik[1000][200];
//char Url[1000][200];
//static int Toplam,Toplam2;
static int restat,Goruntu;
static void draw_menu_key();
int k,adim,kartim2,rkont,zoom,uzunluk[100];
double xcord,ycord,artis;
char Baslik[100][255],server[100][255],Url[100][255],ZooM[100][255],CarpaN[100][255];
//map
int menuatla,renkli,carpan;
char *bmpServer,*isim;
char Url3[500],*secim;
char hata[250];
/// Eklenti resim
//#define FONTNAME "Font1.ttf"
#define FILE_IMAGE "/root/workspace/GoogleMap/image"

#define FONTNAME "/MMP/hd/System/font/Font1.ttf"
//#define FILE_IMAGE "/EMU/GoogleMap/image"
#ifndef FALSE
#define FALSE (0)
#endif

#ifndef TRUE
#define TRUE (!FALSE)
#endif
static GR_FONT_ID font;
static GR_IMAGE_ID PopupBox ;
static GR_IMAGE_ID s_iYellow ;
static GR_IMAGE_ID s_iBlue ;
static GR_IMAGE_ID s_iGreen ;
static GR_IMAGE_ID s_pBgImage ;
static GR_IMAGE_ID s_Alt ;
static GR_IMAGE_ID s_Arka ;
#define ROW1_X 100
#define ROW1_Y 400
#define ROW1_H 15
///
static void ResimYukle(void)
{
PopupBox =GrLoadImageFromFile(FILE_IMAGE"/PopupBox.jpg", FALSE);
s_Alt =GrLoadImageFromFile(FILE_IMAGE"/pan.jpg",FALSE);
s_Arka =GrLoadImageFromFile(FILE_IMAGE"/arka.jpg",FALSE);

}
static void ResimHafiza(void)
{GrFreeImage(PopupBox);
GrFreeImage(s_Alt);
GrFreeImage(s_Arka);
}




typedef struct {

const char *name;
int mode;
// key translation pattern
// 0=DOWN/DOWN/.../UP
// 1=DOWN/DOWN/.../LONG/UP
// 2=DOWN/.../LONG/.../UP
// 3=.../LONG --> DOWN+UP or .../UP --> DOWN/UP
int count;
int key[2];
unsigned short mwkey;

}keys_map_td210;

#define MAX_KEY 60
keys_map_td210 keys_td210[MAX_KEY] = {
{ "MWKEY_ASCII_0", 0, 3, { 0, 4 }, '0'}, // 0 T0
{ "MWKEY_ASCII_1", 0, 3, { 1, 5 }, '1'}, // 1 T1
{ "MWKEY_ASCII_2", 0, 3, { 2, 6 }, '2'}, // 2 T2
{ "MWKEY_ASCII_3", 0, 3, { 3, 7 }, '3'}, // 3 T3
{ "MWKEY_ASCII_4", 0, 3, { 4, 8 }, '4'}, // 4 T4
{ "MWKEY_ASCII_5", 0, 3, { 5, 9 }, '5'}, // 5 T5
{ "MWKEY_ASCII_6", 0, 3, { 6, 10 }, '6'}, // 6 T6
{ "MWKEY_ASCII_7", 0, 3, { 7, 11 }, '7'}, // 7 T7
{ "MWKEY_ASCII_8", 0, 3, { 8, 12 }, '8'}, // 8 T8
{ "MWKEY_ASCII_9", 0, 3, { 9, 13 }, '9'}, // 9 T9
{ "MWKEY_CHANNEL_UP", 0, 3, { 10, 16 }, MWKEY_CHANNEL_UP}, // A CHUP
{ "MWKEY_CHANNEL_DOWN", 0, 3, { 11, 17 }, MWKEY_CHANNEL_DOWN}, // B CHDOWN
{ "Not Allowed", 0, 3, { 12, 18 }, 0}, // C VOLDOWN
{ "Not Allowed", 0, 3, { 13, 19 }, 0}, // D VOLUP
{ "Not Allowed", 2, 6, { 14, 20 }, 0}, // E MUTE
{ "MWKEY_UNKNOWN", 0, 3, { 15, 0 }, MWKEY_UNKNOWN}, // F NONE
{ "MWKEY_ENTER", 0, 3, { 16, 21 }, MWKEY_ENTER}, // 10 OK
{ "MWKEY_MENU", 0, 3, { 17, 22 }, MWKEY_MENU}, // 11 MENU
{ "MWKEY_UP", 0, 3, { 18, 23 }, MWKEY_UP}, // 12 UP
{ "MWKEY_DOWN", 0, 3, { 19, 24 }, MWKEY_DOWN}, // 13 DOWN
{ "MWKEY_LEFT", 0, 3, { 20, 25 }, MWKEY_LEFT}, // 14 LEFT
{ "MWKEY_RIGHT", 0, 3, { 21, 26 }, MWKEY_RIGHT}, // 15 RIGHT
{ "MWKEY_ESCAPE", 0, 3, { 22, 28 }, MWKEY_ESCAPE}, // 16 EXIT
{ "MWKEY_REWIND", 0, 3, { 23, 34 }, MWKEY_REWIND}, // 17 REW
{ "MWKEY_STOP", 0, 3, { 24, 35 }, MWKEY_STOP}, // 18 STOP
{ "MWKEY_PLAY", 0, 3, { 25, 36 }, MWKEY_PLAY}, // 19 PLAY
{ "MWKEY_FAST_FWD", 0, 3, { 26, 37 }, MWKEY_FAST_FWD}, // 1A FWD
{ "MWKEY_TRACK_PREV", 0, 3, { 27, 38 }, MWKEY_TRACK_PREV}, // 1B PREV
{ "MWKEY_TRACK_NEXT", 0, 3, { 28, 39 }, MWKEY_TRACK_NEXT}, // 1C NEXT
{ "MWKEY_RECORD", 0, 3, { 29, 40 }, MWKEY_RECORD}, // 1D RECORD
{ "MWKEY_BACKSPACE", 0, 3, { 30, 14 }, MWKEY_BACKSPACE}, // 1E DEL
{ "MWKEY_UNKNOWN", 0, 3, { 31, 0 }, MWKEY_UNKNOWN}, // 1F NONE
{ "MWKEY_CAPSLOCK", 0, 3, { 32, 15 }, MWKEY_CAPSLOCK}, // 20 CAPS
{ "MWKEY_COLORED_KEY_0", 0, 3, { 33, 58 }, MWKEY_COLORED_KEY_0}, // 21 RED
{ "MWKEY_COLORED_KEY_1", 0, 3, { 34, 59 }, MWKEY_COLORED_KEY_1}, // 22 GREEN
{ "MWKEY_COLORED_KEY_2", 0, 3, { 35, 60 }, MWKEY_COLORED_KEY_2}, // 23 YELLOW
{ "MWKEY_COLORED_KEY_3", 0, 3, { 36, 61 }, MWKEY_COLORED_KEY_3}, // 24 BLUE
{ "MWKEY_GUIDE", 0, 3, { 37, 41 }, MWKEY_GUIDE}, // 25 Guide
{ "MWKEY_F1", 0, 3, { 38, 30 }, MWKEY_F1}, // 26 CHECK
{ "Not Allowed", 0, 3, { 39, 56 }, 0}, // 27 RESOL
{ "MWKEY_INFO", 0, 3, { 40, 47 }, MWKEY_INFO}, // 28 INFO
{ "MWKEY_F2", 0, 3, { 41, 57 }, MWKEY_F2}, // 29 TVRADIO
{ "MWKEY_UNKNOWN", 2, 7, { 42, 1 }, MWKEY_UNKNOWN}, // 2A Power
{ "MWKEY_HOME", 2, 3, { 43, 46 }, MWKEY_HOME}, // 2B Home
{ "Not Allowed", 0, 3, { 44, 53 }, 0}, // 2C UHF
{ "Not Allowed", 0, 3, { 45, 54 }, 0}, // 2D AUX
{ "Not Allowed", 0, 3, { 46, 55 }, 0}, // 2E USB Eject
{ "MWKEY_F3", 0, 3, { 47, 29 }, MWKEY_F3}, // 2F Search
/* New Key */
{ "MWKEY_ESCAPE", 0, 3, { 48, 63 }, MWKEY_ESCAPE}, // 30 UTUBE
{ "MWKEY_ESCAPE", 0, 3, { 49, 64 }, MWKEY_ESCAPE}, // 31 WWW
{ "MWKEY_ESCAPE", 0, 3, { 50, 65 }, MWKEY_ESCAPE}, // 32 EMAIL
/* Front Key */
{ "MWKEY_UP", 0, 3, { 51, 44 }, MWKEY_UP}, // 33 ---UP
{ "MWKEY_DOWN", 0, 3, { 52, 45 }, MWKEY_DOWN}, // 34 ---DOWN
{ "MWKEY_LEFT", 3, 3, { 53, 42 }, MWKEY_LEFT}, // 35 ---LEFT
{ "MWKEY_RIGHT", 3, 3, { 54, 43 }, MWKEY_RIGHT}, // 36 ---RIGHT
{ "MWKEY_HOME", 0, 3, { 55, 46 }, MWKEY_HOME}, // 37 ---LAN(HOME)
//{ "K_LAN__", 0, 3, { 55, 62 }, }, // 37 ---LAN(HOME)
/* Virtual Key */
{ "MWKEY_ESCAPE", 0, 3, { 56, 49 }, MWKEY_ESCAPE}, // 38 SLEEP
{ "MWKEY_ESCAPE", 0, 3, { 57, 50 }, MWKEY_ESCAPE}, // 39 WAKEUP
{ "", 0, 3, { 58, 51 }, MWKEY_UNKNOWN}, // 40 VSLEEP
{ "", 0, 3, { 59, 52 }, MWKEY_UNKNOWN}, // 41 VWAKEUP
};

/* A counter - used so you can see the display being updated. */
static int getSerialNumber(void)
{
static int serial = 0;
if (++serial >= 1000)
serial = 0;
return serial;
}

/* If a character is ASCII, return it, else return a question mark. */
static char keyToChar(int key)
{
if ((key >= 32) && (key <= 127)) {
return (char)key;
} else {
return '?';
}
}

/* Makes a GrGrabKey() type paramater into a human-readable string */
static const char *grabKindName(int kind)
{
switch (kind) {
case GR_GRAB_HOTKEY_EXCLUSIVE:
return "GR_GRAB_HOTKEY_EXCLUSIVE";
case GR_GRAB_HOTKEY:
return "GR_GRAB_HOTKEY";
case GR_GRAB_EXCLUSIVE:
return "GR_GRAB_EXCLUSIVE";
case GR_GRAB_EXCLUSIVE_MOUSE:
return "GR_GRAB_EXCLUSIVE_MOUSE";
default:
return "Invalid GR_GRAB_ mode";
}
}

/* Repaint a specified area of the window */
int repaint(int x, int y, int width, int height)
{ //Sistem ekrana yazırılıyor

font = GrCreateFont(FONTNAME, 10, NULL);
GrSetFontAttr(font, GR_TFANTIALIAS|GR_TFKERNING, 0);
GrSetGCFont(main_gc, font);

GrSetGCForeground(main_gc, GR_RGB(145,139,90) );//Arka platform rengi
GrDrawImageToFit(main_window,main _gc,x,y ,width, height,s_Arka);
//GrFillRect(main_window, main_gc, x, y, width, height);//içi boyalı dikdörtgen

GrSetGCUseBackground(main_gc, GR_FALSE); //DIGTORGEN ARKA PLANINI AL
GrSetGCForeground(main_gc, GR_RGB(58,165,188) );//Arka platform rengi

// GrFillRect(main_window, main_gc, 0, 380, width,60);//içi boyalı dikdörtgen



GrSetGCForeground(main_gc, GR_RGB(50,100,100)); //BUSEKİLDEDE YAZILABİLİR GrGetSysColor(GR_COLOR_APPTEXT) yazi rengi
//GrText(main_window, main_gc, 200, 400, message1, -1, GR_TFASCII);

GrRect(main_window, main_gc,0*75,418,70,20);
GrRect(main_window, main_gc,1*75,418,70,20);
GrRect(main_window, main_gc,2*75,418,70,20);
GrRect(main_window, main_gc,3*75,418,70,20);
GrRect(main_window, main_gc,4*75,418,70,20);
GrRect(main_window, main_gc,5*75,418,70,20);
GrRect(main_window, main_gc,6*75,418,70,20);
GrSetGCForeground(main_gc, GR_RGB(25,100,100));
GrDrawImageToFit(main_window,main _gc,6,10 ,50,50,s_Alt);
GrFillRect(main_window, main_gc,menuatla*75,418,70,20);
GrSetGCForeground(main_gc, GR_RGB(100,100,100));
GrFillRect(main_window,main_gc,60 ,5 ,560,410);


font = GrCreateFont(FONTNAME, 15, NULL);
GrSetFontAttr(font, GR_TFANTIALIAS|GR_TFKERNING, 0);
GrSetGCFont(main_gc, font);
GrSetGCForeground(main_gc, GR_RGB(0,0,255));
GrText(main_window, main_gc, 300 ,200, "Wait......", -1, GR_TFASCII);

//GrRect(main_window, main_gc, 5, 5, WIDTH - 10, 355);
//GrRect(main_window, main_gc, 5,385, WIDTH - 10,50 );
draw_menu_key();
}
/* Repaint the entire window */
static void repaintAll(void)
{
repaint(0,0,WIDTH,HEIGHT);
}

static void Resim_Init(void)
{
ResimYukle();
}



int
main(int argc,char **argv)
{
GR_EVENT event;
GR_WM_PROPERTIES props;
int grabResult;
int key = 'a';
int grabKind = GR_GRAB_HOTKEY_EXCLUSIVE;

isim="geo.txt";
sprintf(Url3,"http://maps.google.com/maps/geo?q=ali&output=txt&key=abcdefg&oe=utf8");
indir (isim,Url3);
Oku2();








DosyaOku();
isim=FILE_IMAGE"/inen.gif";
rkont=0;
if (zoom ==0) zoom=1;
if (carpan==0) carpan=1;
//ycord=0;
//xcord=0;

renkli=0;
artis=50;
secim=0;
//Ekranla bağlantı kur
if (GrOpen() < 0) {
printf("Can't open graphics\n");
exit(1);
}
/* pass errors through main loop*/

GrSetErrorHandler(NULL);
Resim_Init();


main_window = GrNewWindow(GR_ROOT_WINDOW_ID, 20, 20, WIDTH, HEIGHT,
0, GREEN, RED);

props.flags = GR_WM_FLAGS_PROPS | GR_WM_FLAGS_TITLE;
props.props = GR_WM_PROPS_NOBACKGROUND;
props.title = "Nano-X GrabKey Demo";
GrSetWMProperties(main_window, &props);

main_gc = GrNewGC();


grabResult = GrGrabKey(main_window, key, grabKind);
//printf("%d\n", grabResult);

GrSelectEvents(main_window, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ
| GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP);
GrMapWindow(main_window);
GrSetFocus(main_window);

// sprintf(Url3,"http://maps.google.com/staticmap?center=%f,%f&zoom=%d&size=400x400&maptype=%s&key=MAPS_API_KEY&sensor=true_or_false",xcord,ycord,zoom,secim);
//indir (isim,Url3);

for (;;) {

GrGetNextEvent(&event);
switch (event.type)
{
case GR_EVENT_TYPE_EXPOSURE:
repaint(event.exposure.x, event.exposure.y,
event.exposure.width, event.exposure.height);
break;
case GR_EVENT_TYPE_CLOSE_REQ:
GrClose();
exit(0);
break;
case GR_EVENT_TYPE_ERROR:
printf("\7grabdemo: Error (%s) ", event.error.name);
printf(nxErrorStrings[event.error.code],event.error.id);
break;
case GR_EVENT_TYPE_KEY_DOWN:
{
int i;
for(i=0;i<MAX_KEY;i++)
{
if(keys_td210[i].mwkey == event.keystroke.ch)
{

/* sprintf(message1, "%d uuu %03d Keyrrrr %d (%s) scan %d pressed \n",kartim,
getSerialNumber(), event.keystroke.ch,
keys_td210[i].name, event.keystroke.scancode);*/
if (keys_td210[i].name=="MWKEY_UP")
{
xcord=xcord+artis/(zoom*carpan);
//if (xcord>70) xcord=-70;
}
////////////////////////////////////////////////////////////////////////////////
if (keys_td210[i].name=="MWKEY_DOWN")
{
xcord=xcord-artis/(zoom*carpan);
//if (xcord<-70) xcord=70;
}
////////////////////////////////////////////////////////////////////////////////
if (keys_td210[i].name=="MWKEY_LEFT")
{ycord=ycord-artis/(zoom*carpan);//if (ycord<-90) ycord=90;
}
////////////////////////////////////////////////////////////////////////////////
if (keys_td210[i].name=="MWKEY_RIGHT")
{ycord=ycord+artis/(zoom*carpan);//if (ycord>90) ycord=-90;
}
////////////////////////////////////////////////////////////////////////////////
if (keys_td210[i].name=="MWKEY_ENTER")
{
sprintf(hata,"Saving position....");
Bekle(hata);
Sakla();
}
////////////////////////////////////////////////////////////////////////////////
if (keys_td210[i].name=="MWKEY_ASCII_3") //sol MWKEY_CHANNEL_UP
{
zoom=zoom-1;
if (zoom<1) zoom=1;}
////////////////////////////////////////////////////////////////////////////////
if (keys_td210[i].name=="MWKEY_ASCII_4") //sol MWKEY_CHANNEL_DOWN
{
zoom=zoom+1;
}
////////////////////////////////////////////////////////////////////////////////
if (keys_td210[i].name=="MWKEY_COLORED_KEY_0") //sol MWKEY_COLORED_KEY_0
{
menuatla=menuatla-1;
if (menuatla<0) menuatla=6;rkont==0;repaintAll(); }
////////////////////////////////////////////////////////////////////////////////
if (keys_td210[i].name=="MWKEY_COLORED_KEY_1") //sağ MWKEY_COLORED_KEY_1
{
menuatla=menuatla+1;
if (menuatla>6) menuatla=0;
rkont==0;repaintAll(); }
////////////////////////////////////////////////////////////////////////////////
if (keys_td210[i].name=="MWKEY_ASCII_0")
{
if (renkli==0)
{
renkli=1;}
else
{renkli=0;}
}
////////////////////////////////////////////////////////////////////////////////
if (keys_td210[i].name=="MWKEY_ASCII_0") // MWKEY_COLORED_KEY_2
{
carpan=carpan+10;
sprintf(hata,"Step=%d",carpan);
Bekle(hata);
goto atlama;
}

if (keys_td210[i].name=="MWKEY_ASCII_1")// MWKEY_COLORED_KEY_3
{
carpan=carpan-10;
if (carpan <1) carpan=1;

sprintf(hata,"Step=%d",carpan);
Bekle(hata);
goto atlama;
}




break;
}}}

//font = GrCreateFont(FONTNAME, 15, NULL);
//GrSetFontAttr(font, GR_TFANTIALIAS|GR_TFKERNING, 0);
//GrSetGCFont(main_gc, font);

sprintf(hata,"Wait...Downloading file..");
Bekle(hata);
Bekle(hata);
if (menuatla==0) secim="roadmap";
if (menuatla==1) secim="mobile";
if (menuatla==2) secim="satellite";
if (menuatla==3) secim="terrain";
if (menuatla==4) secim="hybrid";
if (menuatla==5) secim="mapmaker-roadmap";
if (menuatla==5) secim="mapmaker-hybrid";
sprintf(Url3,"http://maps.google.com/staticmap?center=%f,%f&zoom=%d&size=550x400&maptype=%s&key=MAPS_API_KEY&sensor=true_or_false",xcord,ycord,zoom,secim);
indir (isim,Url3);
//printf("renkli=%d",renkli);
if (rkont==1)
{Goster();
}
atlama:printf("");
if (rkont==3)
{
sprintf(hata,"error has occurred..");

//hata="error has occurred..";
Bekle(hata);
Bekle(hata);
}

break;
}}
ResimHafiza();
GrClose();
return 0;
}

Goster()
{

GrFreeImage(s_pBgImage);
if (renkli==0)
{s_pBgImage=GrLoadImageFromFile(F ILE_IMAGE"/inen.gif",FALSE);}
else
{
s_pBgImage=GrLoadImageFromFile(FI LE_IMAGE"/inen.gif",TRUE);
}

font = GrCreateFont(FONTNAME, 10, NULL);
GrSetFontAttr(font, GR_TFANTIALIAS|GR_TFKERNING, 0);
GrSetGCFont(main_gc, font);
//GrSetGCForeground(main_gc, GR_RGB(145,139,90) );//Arka platform rengi



GrDrawImageToFit(main_window,main _gc,65,10 ,550,400,s_pBgImage);

}







////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////


int DosyaOku()
{Goruntu=0;
FILE *fp1;
char birkelime;
char *c;
int a,t,f,b;
a=0;f=0;
fp1 = fopen("pozisyon.cfg","r");


do {
// birkelime ='bos';
birkelime = fgetc(fp1);
if (birkelime != NULL);
if (birkelime =='\n' )
{birkelime='\n';
//server[a][f-1]= '\0';//birkelime;
server[a][f+1]= '\0';
uzunluk[a]=f+1;
//printf("****%s--- %d \n",server[a],a);
f=0;
a=a+1;
}
else
{ if (birkelime ==(int) 9 ) goto bak;
if (birkelime ==' ' ) goto bak;
server[a][f]= birkelime;
f=f+1;
// printf("%d \n",birkelime);
bak:printf("");
}

} while (birkelime != '\377' );
fclose(fp1);

a=a;
t=0;
Ayir(a);
}

int Ayir(int Topa)
{int g,uzl,kont,m;

for(g=0;g<Topa;++g)
{kont=0;m=0;
for(uzl=0;uzl<uzunluk[g];++uzl)
{
if(server[g][uzl]==';')
{kont=kont+1;
m=0;
//printf("%d ---kont \n",kont);
goto atla;
}

if(kont==0 )
{
Baslik[g][uzl]=server[g][uzl];
} //kont=0;


if(kont==1 )
{Url[g][m]=server[g][uzl];
m=m+1;

} //kont=0;


if(kont==2 )
{ZooM[g][m]=server[g][uzl];
m=m+1;

} //kont=0;

if(kont==3 )
{CarpaN[g][m]=server[g][uzl];
m=m+1;

} //kont=0;






atla:printf("");
} //uzl

} //g

xcord=atof(Baslik[0]);
ycord=atof(Url[0]);
zoom=atof(ZooM[0]);
carpan=atof(CarpaN[0]);
printf("xcord=%f ycord=%f Zoom=%d Carpan=%d \n",xcord,ycord,zoom,carpan);
}



struct FtpFile {
const char *filename;
FILE *stream;
};

static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream)
{
struct FtpFile *out=(struct FtpFile *)stream;
if(out && !out->stream) {
/* open file for writing */
out->stream=fopen(out->filename, "wb");
if(!out->stream)
return -1; /* failure, can't open file to write */
}
return fwrite(buffer, size, nmemb, out->stream);
}


/*int main(void)
{char *bmpServer,*isim;

bmpServer="http://www.westland.net/photo/file01.jpg";
isim="veli.jpg";
indir(isim,bmpServer);
}*/
indir(char *isim,char *BMPserver)
{ CURL *curl;
CURLcode res;
struct FtpFile ftpfile={isim, /* name to store the file as if succesful */
NULL
};

curl_global_init(CURL_GLOBAL_DEFA ULT);

curl = curl_easy_init();
if(curl) {
/*
* Get curl 7.9.2 from sunet.se's FTP site. curl 7.9.2 is most likely not
* present there by the time you read this, so you'd better replace the
* URL with one that works!
*/
curl_easy_setopt(curl, CURLOPT_URL,BMPserver);
/* Define our callback to get called when there's data to be written */
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);
/* Set a pointer to our struct to pass to the callback */
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile);

/* Switch on full protocol/debug output */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);

res = curl_easy_perform(curl);
printf("%d...\n",res);
if(CURLE_OK == res)
{
// printf("Dosya indirildi...\n");
rkont=1;
}
/* always cleanup */
curl_easy_cleanup(curl);

if(CURLE_OK != res) {
/* we failed */
fprintf(stderr, "curl told us %d\n", res);
//printf("Hata oluştu");
rkont=3;
}
}

if(ftpfile.stream)
fclose(ftpfile.stream); /* close the local file */

curl_global_cleanup();

return 0;
}





int Bekle(char *hata2)
{font = GrCreateFont(FONTNAME, 10, NULL);
GrSetFontAttr(font, GR_TFANTIALIAS|GR_TFKERNING, 0);
GrSetGCFont(main_gc, font);
GrDrawImageToFit(main_window,main _gc,250,200 ,200,50,PopupBox);
GrText(main_window, main_gc, 270 ,225, hata2, -1, GR_TFASCII);
GrDestroyFont(font);
}



static void draw_menu_key()
{

font = GrCreateFont(FONTNAME, 10, NULL);
GrSetFontAttr(font, GR_TFANTIALIAS|GR_TFKERNING, 0);
GrSetGCFont(main_gc, font);
// GrDrawImageToFit(main_window,main _gc,100,400 ,24,23,s_iBlue);
// GrDrawImageToFit(main_window,main _gc,250,400 ,24,23,s_iGreen);
// GrDrawImageToFit(main_window,main _gc,400,400 ,24,23,s_iYellow);
GrSetGCForeground(main_gc, GR_RGB(0,0,0));
GrText(main_window, main_gc, 5 ,433, "roadmap", -1, GR_TFASCII);
GrText(main_window, main_gc, 80 ,433, "mobile", -1, GR_TFASCII);
GrText(main_window, main_gc, 155,433, "satellite", -1, GR_TFASCII);
GrText(main_window, main_gc, 230 ,433, "terrain", -1, GR_TFASCII);
GrText(main_window, main_gc, 305 ,433, "hybrid", -1, GR_TFASCII);
GrText(main_window, main_gc, 380 ,433, "mm-roadmap", -1, GR_TFASCII);
GrText(main_window, main_gc, 455 ,433, "mm-hybrid", -1, GR_TFASCII);
GrSetGCForeground(main_gc, GR_RGB(255,0,0));
GrText(main_window, main_gc, 520 ,433, "www.azbox4yu.com", -1, GR_TFASCII);

GrText(main_window, main_gc, 5 ,450, "Press Ok positions save // Yellow step + // Blue step - // Zoom Out CH+ // Zoom in CH- // Menu-Red-Green // By AzDev", -1, GR_TFASCII);
GrDestroyFont(font);
sleep(1);
Goster();
}


int Sakla()
{
FILE *fp1;
fp1 = fopen("pozisyon.cfg","w");
fprintf(fp1,"%f;%f;%d;%d \n",xcord,ycord,zoom,carpan);
fclose(fp1);
}




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


int Oku2()
{char Anahtar[8],bak[8];
char Adres[100][500],KordX[100][500],KordY[100][500];
int d;
FILE *fp1;
char birkelime[500];
char *c;
d=0;
fp1 = fopen("geo.txt","r");
do {
c = fgets(birkelime,100,fp1); /* bir satir okuyalim */
if (c != NULL)
Anahtar[0]=birkelime[5];//a-c
Anahtar[1]=birkelime[6];//d-o
Anahtar[2]=birkelime[7];//d-o
Anahtar[3]=birkelime[8];//r-r
Anahtar[4]=birkelime[9];//e-d
Anahtar[5]=birkelime[10];//s-i
Anahtar[6]=birkelime[11];//s-n
Anahtar[7]='\0';//s-n
bak[0]='a';//-c
bak[1]='d';//-o
bak[2]='d';//-o
bak[3]='r';//-r
bak[4]='e';//-d
bak[5]='s';//-i
bak[6]='s';//-n
bak[7]='\0';//-n
if (strcmp(Anahtar,bak)==0)
{
int uzk,uzr;
uzr=strlen(birkelime);

for(uzk=16;uzk<uzr;++uzk)
{
Adres[d][uzk-16]=birkelime[uzk];

}
Adres[d][uzk-19]='\0';
//sprintf(Adres[a],"%s",birkelime);
printf("Adres=%s \n",Adres[d]);
d=d+1;
}

bak[0]=' ';//-c
bak[1]='"';//-o
bak[2]='c';//-o
bak[3]='o';//-r
bak[4]='o';//-d
bak[5]='r';//-i
bak[6]='d';//-n
bak[7]='\0';//-n

if (strcmp(Anahtar,bak)==0)
{
int uzk,uzr,korty,cm;
uzr=strlen(birkelime);
korty=0;
cm=0;
for(uzk=23;uzk<uzr;++uzk)
{
if (birkelime[uzk]==',') { korty=korty+1;cm=0;goto gh;}
if (birkelime[uzk]==' ') { goto gh;}
if (korty==0) {KordX[d][cm]=birkelime[uzk];}
if (korty==1) {KordY[d][cm]=birkelime[uzk];}
cm=cm+1;
gh:printf("");
}
printf("Kordinat kort=%d<-->%s/%s\n",korty,KordX[d],KordY[d]);
}
} while (c != NULL);
fclose(fp1);
}

kanber_kav
04-09-2009, 08:49 AM
continue ...

Kanber KAV (Az-Dev)

goran
04-09-2009, 12:46 PM
And long may you continue, m8!!!:respect-067:

Thank you kindly!!!!:bravo-009::cheers2: