Patch out cursor-code, update code

The cursor code (LocalToGlobal, HideCursor, ObscureCursor) is not present.
The update code (using curl) will be replaced with Sparkle.
This commit is contained in:
maride 2016-04-02 16:01:44 +02:00
parent 4a8a562af5
commit 73dfb0e950

View File

@ -5,10 +5,6 @@
#include <pthread.h> #include <pthread.h>
#include <unistd.h> #include <unistd.h>
#include <curl/curl.h>
#include <curl/types.h> /* new for v7 */
#include <curl/easy.h> /* new for v7 */
#include "controls.h" #include "controls.h"
#include "initexit.h" #include "initexit.h"
#include "config.h" #include "config.h"
@ -589,7 +585,7 @@ void SystemPoll(int inGame)
Rect dragRect={0,0,32767,32767}; Rect dragRect={0,0,32767,32767};
DragWindow(win,evt.where,&dragRect); DragWindow(win,evt.where,&dragRect);
Point pt={0,0}; Point pt={0,0};
LocalToGlobal(&pt); // LocalToGlobal(&pt);
gConfig->windowX=pt.h; gConfig->windowX=pt.h;
gConfig->windowY=pt.v; gConfig->windowY=pt.v;
} }
@ -671,10 +667,10 @@ void SystemPoll(int inGame)
if(TimeGetSeconds()>gLastCursorHideTime+1&&!gSystemInstalling) if(TimeGetSeconds()>gLastCursorHideTime+1&&!gSystemInstalling)
{ {
gLastCursorHideTime=TimeGetSeconds(); gLastCursorHideTime=TimeGetSeconds();
if(gConfig->fullscreen) //if(gConfig->fullscreen)
HideCursor(); // HideCursor();
else //else
ObscureCursor(); // ObscureCursor();
} }
if(((!gInterfaceType||GetInterfaceKey(kInterfaceKeyCmd))||inGame)&&!gSystemSuspended) if(((!gInterfaceType||GetInterfaceKey(kInterfaceKeyCmd))||inGame)&&!gSystemSuspended)
@ -705,7 +701,6 @@ void SystemPoll(int inGame)
iTunesPress=false; iTunesPress=false;
} }
RT3_Idle();
NetworkIdle(); NetworkIdle();
SystemIdle(); SystemIdle();
} }
@ -784,139 +779,4 @@ float TimeGetSeconds()
UInt64 w; UInt64 w;
Microseconds((UnsignedWide*)&w); Microseconds((UnsignedWide*)&w);
return (float)((double)(w-startTime)*(double)0.000001); return (float)((double)(w-startTime)*(double)0.000001);
}
size_t my_write_func(void *ptr, size_t size, size_t nmemb, FILE *stream)
{
return fwrite(ptr, size, nmemb, stream);
}
size_t my_read_func(void *ptr, size_t size, size_t nmemb, FILE *stream)
{
return fread(ptr, size, nmemb, stream);
}
int my_progress_func(void *v,
double t, /* dltotal */
double d, /* dlnow */
double ultotal,
double ulnow)
{
char status[1024];
float time=TimeGetSeconds()-gInstallStartTime;
if(d>0)
{
time*=(t-d)/d;
sprintf(status,"%3.1f of %3.1fMB - about %d:%02d:%02d remaining",d/(1024*1024),t/(1024*1024),(int)(time/3600),((int)(time/60))%60,((int)time)%60);
}
else
sprintf(status,"%3.1f of %3.1fMB");
InterfaceDrawStatusBar("Downloading new version",status,d/t);
SystemPoll(false);
return 0;
}
int CurlGetFile(char *url,char *filename,char *failStr)
{
#ifndef __TARGET_TOOLAPP
CURL *curl;
CURLcode res;
FILE *outfile;
if(!curl_easy_init)
{
strcpy(failStr,"libcurl not available");
return false;
}
curl = curl_easy_init();
if(curl)
{
outfile = fopen(filename, "w");
if(!outfile)
{
strcpy(failStr,"Couldn't create file.\nMake sure that Redline and the Redline directory is writable and that you have free space on your disk.");
return false;
}
gSystemInstalling=true;
gInstallStartTime=TimeGetSeconds();
res = curl_easy_setopt(curl, CURLOPT_URL, url);
if(res==CURLE_OK) res = curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile);
if(res==CURLE_OK) res = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_write_func);
if(res==CURLE_OK) res = curl_easy_setopt(curl, CURLOPT_READFUNCTION, my_read_func);
if(res==CURLE_OK) res = curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE);
if(res==CURLE_OK) res = curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, my_progress_func);
if(res==CURLE_OK) res = curl_easy_perform(curl);
fclose(outfile);
/* always cleanup */
curl_easy_cleanup(curl);
}
switch(res)
{
case CURLE_OK: break;
case 22: strcpy(failStr,"curl: HTTP error"); break;
case CURLE_WRITE_ERROR: strcpy(failStr,"curl: Error writing to disk"); break;
case CURLE_URL_MALFORMAT: strcpy(failStr,"curl: Invalid Update URL"); break;
case CURLE_COULDNT_RESOLVE_HOST: strcpy(failStr,"curl: Couldn't resolve host"); break;
case CURLE_COULDNT_CONNECT: strcpy(failStr,"curl: Connection failed"); break;
case CURLE_OPERATION_TIMEOUTED: strcpy(failStr,"curl: Connection timed out"); break;
case CURLE_RECV_ERROR: strcpy(failStr,"curl: Error receiving data"); break;
default: strcpy(failStr,"curl: Error downloading URL"); break;
}
return res==CURLE_OK;
#endif
}
void SystemExit()
{
if(gSystemInstalling)
system("rm redlineupdatearchive.zip");
}
int AutoUpdateRedline(char *updateURL,char *failStr)
{
CFBundleRef refMainBundle = CFBundleGetMainBundle();
if (!refMainBundle)
{
sprintf(failStr,"Couldn't get Redline bundle location");
return false;
}
// create a URL to the app bundle
CFURLRef refMainBundleURL = CFBundleCopyBundleURL (refMainBundle);
if(!refMainBundleURL)
{
sprintf(failStr,"Couldn't get Redline bundle location");
return false;
}
char path[512];
if(!CFURLGetFileSystemRepresentation(refMainBundleURL,true,(UInt8*)path,512))
{
sprintf(failStr,"Couldn't get Redline bundle location");
return false;
}
// char cmd[512];
sprintf(path,"%s/../",path);
chdir(path);
system("pwd");
// printf(cmd);
// system(cmd);
int retval=true;
InitCursor();
if(!CurlGetFile(updateURL,"redlineupdatearchive.zip",failStr)) retval=false;
InterfaceDrawStrings("Installing new version","Please wait a moment...",-1);
if(retval)
if(system("unzip -o redlineupdatearchive.zip"))
{
retval=false;
sprintf(failStr,"Couldn't unzip update archive.\nMake sure that Redline and the Redline directory is writable and that you have free space on your disk.");
}
if(system("rm redlineupdatearchive.zip")) retval=false;
gSystemInstalling=false;
return retval;
} }