Skip to content
This repository has been archived by the owner on Aug 6, 2019. It is now read-only.

Commit

Permalink
V110
Browse files Browse the repository at this point in the history
  • Loading branch information
Smanar committed Jul 18, 2016
1 parent b63bfe5 commit 97c1ae8
Show file tree
Hide file tree
Showing 17 changed files with 685 additions and 210 deletions.
109 changes: 82 additions & 27 deletions rhonda/applications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,10 @@ bool LoadData(void)
}

/******************************************************/
char ville[20];

std::string ville;
void SetCity(char *s)
{
int l = strlen(s);
if (l > 19) l = 19;
strncpy(ville, s, l);
ville = s;
}

int GetMeteo(wchar_t *s)
Expand All @@ -279,7 +276,7 @@ int GetMeteo(wchar_t *s)

char url[255];
strcpy(url, "http://www.prevision-meteo.ch/services/json/");
strcat(url, ville);
strcat(url, ville.c_str());

char *html = LectureWeb(url);

Expand All @@ -288,12 +285,13 @@ int GetMeteo(wchar_t *s)
{
if (caps[0].len < 255)
{
char *tmp = (char *)malloc((caps[0].len + 1) * sizeof(char));
char *tmp = (char *)malloc((caps[0].len + 10) * sizeof(char));
strncpy(tmp,caps[0].ptr,caps[0].len);
strncpy(tmp + caps[0].len ,"\0", 1);
tmp[caps[0].len] = '\0';
//mbstowcs(s, tmp, caps[0].len+1);
mymbstowcs(s, tmp, caps[0].len+1);
mymbstowcs(s, tmp, caps[0].len);
//swprintf(s, 100, L"%hs", caps[0].ptr);
free(tmp);
}
}

Expand All @@ -311,7 +309,7 @@ int GetDefinition(char *mot, wchar_t * def)
char url[255];
char *html;

int Maxlen = 800;
//int Maxlen = 800;

char *search;

Expand All @@ -335,15 +333,15 @@ int GetDefinition(char *mot, wchar_t * def)
char buff[800];

/* Max 800 char */
if (caps[0].len > 800) caps[0].len = 800;
if (caps[0].len > 800) caps[0].len = 800;

strncpy(buff,caps[0].ptr,caps[0].len);
strncpy(buff + caps[0].len ,"\0", 1);
strncpy(buff, caps[0].ptr, caps[0].len);
strncpy(buff + caps[0].len, "\0", 1);

#ifdef _WIN32
//UnicodeToAnsi(buff,tmp);
//UnicodeToAnsi(buff,tmp);
#endif
mymbstowcs(def, buff, caps[0].len);
mymbstowcs(def, buff, caps[0].len);

}

Expand All @@ -363,7 +361,7 @@ int GetFilmCinema(wchar_t *s, int len)
char *posbuf = buff;
char *posHtml;

int Maxlen = 800;
//int Maxlen = 800;
len -= 1;

html = LectureWeb("http://www.commeaucinema.com/rsspage.php?feed=cine");
Expand Down Expand Up @@ -421,28 +419,85 @@ void ClearMusic(void)

/*******************************************************/

char MailUser[50];
char MailPass[50];

void SetMailUserPass(char *u, char *p)
void SendRequest(char *url)
{
int l = strlen(u);
if (l > 49) l = 49;
strncpy(MailUser, u, l);
char *html = LectureWeb(url);

free(html);
}

/*******************************************************/

l = strlen(p);
if (l > 49) l = 49;
strncpy(MailPass, p, l);
std::string MailUser_and_pass;

void SetMailUserPass(char *s)
{
MailUser_and_pass = s;
}
int CheckMail(void)
{

if (MailUser_and_pass.empty()) return -1;

int mail = 0;
mail = OpenMailServer(MailUser, MailPass);
if (strstr(MailUser_and_pass.c_str(), "@gmail") != NULL)
{
mail = check_gmail((char*)MailUser_and_pass.c_str());
}
else
{
mail = 0;// OpenMailServer(MailUser_and_pass);
}

return mail;
}

/******************************************************/

std::string GitHub_Account;
void SetGitHubUserPass(char *s)
{
GitHub_Account = s;
}
int CheckGitHubNotification(void)
{
if (GitHub_Account.empty()) return -1;

return check_github((char *)GitHub_Account.c_str());
}
/******************************************************/
int RSS_Mem_lengh = 0;
std::string RSS_site;

void SetRSS_Site(char *s)
{
RSS_site = s;
RSSMonitor();
}

int RSSMonitor()
{
int l;
char *tmp;

if (RSS_site.empty()) return -1;

tmp = LectureWeb((char *)RSS_site.c_str());
l = strlen(tmp);
free(tmp);

if (RSS_Mem_lengh == 0)
{
Mywprintf(L"Memorisation du RSS du site : %s\n", (char *)RSS_site.c_str());
RSS_Mem_lengh = l;
}
else if (RSS_Mem_lengh != l)
{
return 1;
}

return 0;
}

/******************************************************/
//http://stackoverflow.com/questions/478898/how-to-execute-a-command-and-get-output-of-command-within-c-using-posix
Expand Down
11 changes: 10 additions & 1 deletion rhonda/applications.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ void lireshell(char *command);
void executesCommand(char*);

int CheckMail(void);
void SetMailUserPass(char *u, char *p);
void SetMailUserPass(char *);

void SetGitHubUserPass(char *s);
int CheckGitHubNotification();

void SendRequest(char *);

void SetRSS_Site(char *s);
int RSSMonitor();

int GetFilmCinema(wchar_t *s,int l);

void Savedata(void);
Expand Down
2 changes: 1 addition & 1 deletion rhonda/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ int cRecord::RecordFLAC(const char *fileName, uint32_t duration)
writeWAVHeaderBuffer(WavBuffer,hdr);
memcpy(WavBuffer+44,data.recordedSamples,NUM_CHANNELS * sizeof(SAMPLE) * data.frameIndex);

printf("Sound recorded, convertion\n");
printf("Sound recorded, convertion to flac\n");
ConvertFlacBuffer(WavBuffer,size, fileName);
if (WavBuffer) free(WavBuffer);
}
Expand Down
16 changes: 11 additions & 5 deletions rhonda/config.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?xml version="1.0"?>
<mesh name="mesh_root">
<!-- configuration-->
<!-- configuration -->
<config>
<api>XXXXXXXXXXXXXXXXXXXXXXXXXXXxx</api>
<api>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</api>
<ville>paris</ville>
<mailuser>user</mailuser>
<mailpass>pass</mailpass>
<cinemaurl>http://www.commeaucinema.com/rsspage.php?feed=cine</cinemaurl>
<RSS_Site>http://www.site.com/forum/index.php?type=rss;action=.xml</RSS_Site>
<!-- La syntaxe pour les infos suivante est user:mot_de_passe -->
<mailuser_and_pass>user:pass</mailuser_and_pass>
<githubaccount>user:pass</githubaccount>
</config>
<!-- configuration du son-->
<!-- Gain_record = gain a appliquer au micro durant enregistrement -->
Expand Down Expand Up @@ -41,6 +43,8 @@
<LC command="etein(ts) lumiere///" action = "15" />
<LC command="*QUESTION au cinema///" action = "16" />
<LC command="affiche icone tete///" action = "17" />
<LC command="*QUESTION de neuf///" action = "19" />
<LC command="test requete serveur///" action = "20" />
</commandlist>
<!-- dictionnaire special -->
<special>
Expand Down Expand Up @@ -72,6 +76,8 @@
<ACT index="16" action="CINEMA" />
<ACT index="17" action="SHOWICON 3" />
<ACT index="18" action="MUSIQUE OFF" />
<ACT index="19" action="CHECKMAIL | CHECKGITHUB | CHECKRSS" />
<ACT index="20" action="SENDREQUEST http://xx.xx.xx.xx:8080/json.htm?type=command&amp;param=switchlight&amp;idx=220&amp;switchcmd=On" />
</action>
<!-- icones pour la matrice -->
<!-- 1=sablier 2=micro 3=smiley 4=interrogation 5/6=anim alien 7=coeur 8=clock 9=mail-->
Expand All @@ -91,7 +97,7 @@
<!-- Format YY/MM/DD/HH/MM -->
<Event>
<Al time="XX/XX/XX/07/00" action="DIRE bone journee" />
<Al time="XX/XX/XX/XX/10" action="SHOWICON 8 | DIRE test" />
<Al time="XX/XX/XX/XX/00" action="SHOWICON 8 | CHECKGITHUB | CHECKRSS" />
</Event>
</mesh>
<?include somedata?>
17 changes: 10 additions & 7 deletions rhonda/flac.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <string.h>

#include "flac.h"
#include <wchar.h>

//#include "FLAC/metadata.h"
#include "FLAC/stream_encoder.h"
Expand All @@ -45,6 +46,8 @@ static unsigned total_samples = 0; /* can use a 32-bit number due to WAVE size l
static FLAC__byte buffer[READSIZE/*samples*/ * 2/*bytes_per_sample*/ * 1/*channels*/]; /* we read the WAVE data into here */
static FLAC__int32 pcm[READSIZE/*samples*/ * 1/*channels*/];

#if 0

int ConvertFlac(char * sour, char * dest)
{
FLAC__bool ok = true;
Expand Down Expand Up @@ -144,7 +147,7 @@ int ConvertFlac(char * sour, char * dest)

return 1;
}

#endif

int ConvertFlacBuffer(char * sour, long size, const char * dest)
{
Expand All @@ -171,7 +174,7 @@ int ConvertFlacBuffer(char * sour, long size, const char * dest)
*/
if (size < 44)
{
fprintf(stderr, "ERROR: Buffer problem\n");
wprintf(L"ERROR: Buffer problem\n");
}
memcpy(buffer,sour,44);
size -= 44;
Expand All @@ -184,7 +187,7 @@ int ConvertFlacBuffer(char * sour, long size, const char * dest)
total_samples = (((((((unsigned)buffer[43] << 8) | buffer[42]) << 8) | buffer[41]) << 8) | buffer[40]) / 2;// par 2 au lieu de 4
/* allocate the encoder */
if((encoder = FLAC__stream_encoder_new()) == NULL) {
fprintf(stderr, "ERROR: allocating encoder\n");
wprintf(L"ERROR: allocating encoder\n");
return 0;
}

Expand All @@ -202,7 +205,7 @@ int ConvertFlacBuffer(char * sour, long size, const char * dest)
if(ok) {
init_status = FLAC__stream_encoder_init_file(encoder, dest, progress_callback, /*client_data=*/NULL);
if(init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK) {
fprintf(stderr, "ERROR: initializing encoder: %s\n", FLAC__StreamEncoderInitStatusString[init_status]);
wprintf(L"ERROR: initializing encoder: %s\n", FLAC__StreamEncoderInitStatusString[init_status]);
ok = false;
}
}
Expand All @@ -214,7 +217,7 @@ int ConvertFlacBuffer(char * sour, long size, const char * dest)
size_t need = (left>READSIZE? (size_t)READSIZE : (size_t)left);
//if(fread(buffer, channels*(bps/8), need, fin) != need) {
if (size < (long)(channels*(bps/8) * need )) {
fprintf(stderr, "ERROR: reading from buffer\n");
wprintf(L"ERROR: reading from buffer\n");
ok = false;
}
else {
Expand All @@ -238,8 +241,8 @@ int ConvertFlacBuffer(char * sour, long size, const char * dest)

ok &= FLAC__stream_encoder_finish(encoder);

fprintf(stderr, "encoding: %s\n", ok? "succeeded" : "FAILED");
fprintf(stderr, "state: %s\n", FLAC__StreamEncoderStateString[FLAC__stream_encoder_get_state(encoder)]);
wprintf(L"encoding: %s\n", ok? L"succeeded" : L"FAILED");
wprintf(L"state: %s\n", FLAC__StreamEncoderStateString[FLAC__stream_encoder_get_state(encoder)]);

FLAC__stream_encoder_delete(encoder);

Expand Down
Loading

0 comments on commit 97c1ae8

Please sign in to comment.