Skip to content

Commit

Permalink
WinRT specific stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
john-blackburn committed Apr 2, 2015
1 parent 1034e1e commit 19ae157
Show file tree
Hide file tree
Showing 158 changed files with 9,970 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,6 @@ tmp
!*.nsi

# and others to exclude
*.filters
*.vcxitems
plugins/LPeg/source/makefile
/.project
/Default/
45 changes: 45 additions & 0 deletions libgid/include/winrt/ghttp-winrt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#ifndef GHTTPQT_H
#define GHTTPQT_H

#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
class QAuthenticator;
class QNetworkProxy;
#include <deque>
#include <map>

#include <ghttp.h>

class HTTPManager : public QObject
{
Q_OBJECT

public:
HTTPManager();
~HTTPManager();

g_id Get(const char* url, const ghttp_Header *header, gevent_Callback callback, void* udata);
g_id Post(const char* url, const ghttp_Header *header, const void* data, size_t size, gevent_Callback callback, void* udata);
g_id Delete(const char* url, const ghttp_Header *header, gevent_Callback callback, void* udata);
g_id Put(const char* url, const ghttp_Header *header, const void* data, size_t size, gevent_Callback callback, void* udata);
void Close(g_id id);
void CloseAll();

private slots:
void finished(QNetworkReply *reply);
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);

private:
QNetworkAccessManager *manager_;

struct NetworkReply
{
g_id id;
gevent_Callback callback;
void *udata;
};
std::map<QNetworkReply*, NetworkReply> map_;
};

#endif
20 changes: 20 additions & 0 deletions libgid/include/winrt/ginput-winrt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef _GINPUT_WINRT_H_
#define _GINPUT_WINRT_H_

#include <gglobal.h>

#ifdef __cplusplus
extern "C" {
#endif

G_API void ginputp_mouseDown(int x, int y, int button);
G_API void ginputp_mouseMove(int x, int y);
G_API void ginputp_mouseUp(int x, int y, int button);
G_API void ginputp_keyDown(int keyCode);
G_API void ginputp_keyUp(int keyCode);

#ifdef __cplusplus
}
#endif

#endif
86 changes: 86 additions & 0 deletions libgid/include/winrt/gui-winrt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#ifndef _GUI_QT_H_
#define _GUI_QT_H_

#include <QDialog>
#include <gui.h>
#include <QMap>

class QAbstractButton;
class QStringList;
class UIManager;
class QLineEdit;

class AlertDialog : public QDialog
{
Q_OBJECT

public:
AlertDialog(const char *title,
const char *message,
const char *cancelButton,
const char *button1,
const char *button2,
gevent_Callback callback,
void *udata,
g_id gid,
QWidget *parent = 0);

protected:
virtual void closeEvent(QCloseEvent *);

private slots:
void clicked(QAbstractButton *button);

private:
gevent_Callback callback_;
void *udata_;
g_id gid_;

private:
QMap<QAbstractButton*, int> buttonIndices_;
QAbstractButton *cancelButton_;
};

class TextInputDialog : public QDialog
{
Q_OBJECT

public:
TextInputDialog(const char *title,
const char *message,
const char *text,
const char *cancelButton,
const char *button1,
const char *button2,
gevent_Callback callback,
void *udata,
g_id gid,
QWidget *parent = 0);

public:
void setText(const char* text);
const char *getText() const;
void setInputType(int inputType);
int getInputType() const;
void setSecureInput(bool secureInput);
bool isSecureInput() const;

protected:
virtual void closeEvent(QCloseEvent *);

private slots:
void clicked(QAbstractButton *button);

private:
gevent_Callback callback_;
void *udata_;
g_id gid_;
QLineEdit *lineEdit_;
mutable QByteArray lineEditBuffer_;

private:
QMap<QAbstractButton*, int> buttonIndices_;
QAbstractButton *cancelButton_;
};

#endif
36 changes: 36 additions & 0 deletions libgid/src/winrt/gapplication-winrt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <gapplication.h>


extern "C" {

void gapplication_init()
{

}

void gapplication_cleanup()
{

}

int gapplication_getScreenDensity()
{
return -1;
}

g_id gapplication_addCallback(gevent_Callback callback, void *udata)
{
return 0;
}

void gapplication_removeCallback(gevent_Callback callback, void *udata)
{

}

void gapplication_removeCallbackWithGid(g_id gid)
{

}

}
63 changes: 63 additions & 0 deletions libgid/src/winrt/gaudio-winrt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include <gaudio.h>
#include <mpg123.h>
#include "../ggaudiomanager.h"

extern "C" {
GGSampleInterface *GGSampleXAudio2ManagerCreate();
void GGSampleXAudio2ManagerDelete(GGSampleInterface *manager);

GGStreamInterface *GGStreamXAudio2ManagerCreate();
void GGStreamXAudio2ManagerDelete(GGStreamInterface *manager);
}

void GGAudioManager::systemInit()
{
mpg123_init();
}

void GGAudioManager::systemCleanup()
{
mpg123_exit();
}

void GGAudioManager::createBackgroundMusicInterface()
{
backgroundMusicInterface_ = NULL;
}

void GGAudioManager::deleteBackgroundMusicInterface()
{
}

void GGAudioManager::beginInterruption()
{
}

void GGAudioManager::endInterruption()
{
}

void GGAudioManager::AdvanceStreamBuffers()
{
soundManager_->AdvanceStreamBuffers();
}

void GGSoundManager::interfacesInit()
{
loaders_["wav"] = GGAudioLoader(gaudio_WavOpen, gaudio_WavClose, gaudio_WavRead, gaudio_WavSeek, gaudio_WavTell);
loaders_["mp3"] = GGAudioLoader(gaudio_Mp3Open, gaudio_Mp3Close, gaudio_Mp3Read, gaudio_Mp3Seek, gaudio_Mp3Tell);

sampleInterface_ = GGSampleXAudio2ManagerCreate();
streamInterface_ = GGStreamXAudio2ManagerCreate();
}

void GGSoundManager::interfacesCleanup()
{
GGSampleXAudio2ManagerDelete(sampleInterface_);
GGStreamXAudio2ManagerDelete(streamInterface_);
}

void GGSoundManager::AdvanceStreamBuffers()
{
streamInterface_->AdvanceStreamBuffers();
}
84 changes: 84 additions & 0 deletions libgid/src/winrt/ggeolocation-winrt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#include "ggeolocation.h"

#ifdef __cplusplus
extern "C" {
#endif

void ggeolocation_init()
{

}

void ggeolocation_cleanup()
{

}

int ggeolocation_isAvailable()
{
return 0;
}

int ggeolocation_isHeadingAvailable()
{
return 0;
}

void ggeolocation_setAccuracy(double accuracy)
{

}

double ggeolocation_getAccuracy()
{
return 0;
}

void ggeolocation_setThreshold(double threshold)
{

}

double ggeolocation_getThreshold()
{
return 0;
}

void ggeolocation_startUpdatingLocation()
{

}

void ggeolocation_stopUpdatingLocation()
{

}

void ggeolocation_startUpdatingHeading()
{

}

void ggeolocation_stopUpdatingHeading()
{

}

g_id ggeolocation_addCallback(gevent_Callback callback, void *udata)
{
return 0;
}

void ggeolocation_removeCallback(gevent_Callback callback, void *udata)
{

}

void ggeolocation_removeCallbackWithGid(g_id gid)
{

}

#ifdef __cplusplus
}
#endif
50 changes: 50 additions & 0 deletions libgid/src/winrt/ghttp-winrt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <ghttp.h>

extern "C" {

void ghttp_Init()
{
// s_manager = new HTTPManager();
}

void ghttp_Cleanup()
{
// delete s_manager;
// s_manager = NULL;
}

g_id ghttp_Get(const char* url, const ghttp_Header *header, gevent_Callback callback, void* udata)
{
// return s_manager->Get(url, header, callback, udata);
return 0;
}

g_id ghttp_Post(const char* url, const ghttp_Header *header, const void* data, size_t size, gevent_Callback callback, void* udata)
{
// return s_manager->Post(url, header, data, size, callback, udata);
return 0;
}

g_id ghttp_Delete(const char* url, const ghttp_Header *header, gevent_Callback callback, void* udata)
{
// return s_manager->Delete(url, header, callback, udata);
return 0;
}

g_id ghttp_Put(const char* url, const ghttp_Header *header, const void* data, size_t size, gevent_Callback callback, void* udata)
{
// return s_manager->Put(url, header, data, size, callback, udata);
return 0;
}

void ghttp_Close(g_id id)
{
// s_manager->Close(id);
}

void ghttp_CloseAll()
{
// s_manager->CloseAll();
}

}
Loading

0 comments on commit 19ae157

Please sign in to comment.