Skip to content
This repository has been archived by the owner on Jul 4, 2020. It is now read-only.

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
codestation committed Aug 11, 2013
0 parents commit f9347f3
Show file tree
Hide file tree
Showing 34 changed files with 4,494 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
qcma.pro.user*
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
QCMA
====

QCMA is an cross-platform application to provide a Open Source implementation
of the original Content Manager Assistant that comes with the PS Vita. QCMA is
meant to be compatible with Linux, Windows and MAC OS X.

## Features

The aim of this project is to provide a implementation that is on par with the
official CMA and also offer some features missing in the original one.

#### Implemented features missing in OpenCMA (Yifan Lu CLI application)
* Metadata for PSP savedatas.
* Basic metadata for single songs (album, artist, title).
* Basic metadata for videos (duration, dimensions).
* Basic metadata for photos (dimensions).
* Easy wireless pairing (show PIN to the user when a Vita is detected).
* Ability to restart the connection if the Vita is reconnected (on test).
* Ability to change the connection mode (usb/wireless) on the fly (on test).

#### TODO:
* Fix remaining bugs with thread synchronizations.
* Implement thumbnails for videos and album art for music.
* Folder categories for music/videos.
* SQLite backend for database.
* Fix wireless streaming for music/videos.

## Planned features
* **Backup browser**: provide a human readable listing of the games saved on the
computer (name, icon, side on disk) and provide some actions (delete savedata,
patches or the whole game without need of the Vita). Also some sort of interface
to prepare VHBL homebrew in the folder of the exploited savedata.

* **DLNA bridge**: connect an existing DLNA server to interface with the Vita
using the wireless streaming feature.

#### Dependencies
* [Qt 4.x or 5.x](http://qt-project.org/)

* [VitaMTP](https://github.com/yifanlu/VitaMTP)

* [MediaInfo](http://mediaarea.net/en/MediaInfo)


#### Where do I get the source code?
Check the GitHub repo here: https://github.com/codestation/qcma

#### I want to contribute
Contact me on [GitHub](https://github.com/codestation/)

#### Thanks to
[Yifan Lu](https://github.com/yifanlu/vitamtp/) - for the vitamtp library and
the reference implementation of OpenCMA.

#### License
GPL v3: since some parts of QCMA are based on the reference implementation of
OpenCMA.
57 changes: 57 additions & 0 deletions baseworker.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* QCMA: Cross-platform content manager assistant for the PS Vita
*
* Copyright (C) 2013 Codestation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "baseworker.h"

BaseWorker::BaseWorker(QObject *parent) :
QObject(parent)
{
thread = NULL;
}

void BaseWorker::onFinished()
{
}

void BaseWorker::start()
{
thread = new QThread();

// Move this service to a new thread
this->moveToThread(thread);

// The main loop will be executed when the thread
// signals that it has started.
connect(thread, SIGNAL(started()), this, SLOT(process()));

// Make sure that we notify ourselves when the thread
// is finished in order to correctly clean-up the thread.
connect(thread, SIGNAL(finished()), this, SLOT(onFinished()));

// The thread will quit when the sercives
// signals that it's finished.
connect(this, SIGNAL(finished()), thread, SLOT(quit()));

// The thread will be scheduled for deletion when the
// service signals that it's finished
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));

// Start the thread
thread->start();
}
48 changes: 48 additions & 0 deletions baseworker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* QCMA: Cross-platform content manager assistant for the PS Vita
*
* Copyright (C) 2013 Codestation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef BASEWORKER_H
#define BASEWORKER_H

#include <QObject>
#include <QThread>

class BaseWorker : public QObject
{
Q_OBJECT

public:
explicit BaseWorker(QObject *parent = 0);

void start();

private:
QThread *thread;

signals:
void finished();

protected slots:
virtual void process() = 0;

private slots:
virtual void onFinished();
};

#endif // BASEWORKER_H
112 changes: 112 additions & 0 deletions capability.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* QCMA: Cross-platform content manager assistant for the PS Vita
*
* Copyright (C) 2013 Codestation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "capability.h"

#include <QDebug>
#include <QHostInfo>

bool DeviceCapability::exchangeInfo(vita_device_t *device)
{
if(VitaMTP_GetVitaInfo(device, &vita_info) != PTP_RC_OK) {
qWarning("Cannot retreve device information.");
return false;
}

if(vita_info.protocolVersion > VITAMTP_PROTOCOL_MAX_VERSION) {
qWarning("Vita wants protocol version %08d while we only support %08d. Attempting to continue.",
vita_info.protocolVersion, VITAMTP_PROTOCOL_MAX_VERSION);
}

QString hostname = QHostInfo::localHostName();
const initiator_info_t *pc_info = VitaMTP_Data_Initiator_New(hostname.toUtf8().data(), vita_info.protocolVersion);

// Next, we send the client's (this program) info (discard the const here)
if(VitaMTP_SendInitiatorInfo(device, (initiator_info_t *)pc_info) != PTP_RC_OK) {
qWarning("Cannot send host information.");
return false;
}

if(vita_info.protocolVersion >= VITAMTP_PROTOCOL_FW_2_10) {
// Get the device's capabilities
capability_info_t *vita_capabilities;

if(VitaMTP_GetVitaCapabilityInfo(device, &vita_capabilities) != PTP_RC_OK) {
qWarning("Failed to get capability information from Vita.");
return false;
}

VitaMTP_Data_Free_Capability(vita_capabilities); // TODO: Use this data
// Send the host's capabilities
capability_info_t *pc_capabilities = generate_pc_capability_info();

if(VitaMTP_SendPCCapabilityInfo(device, pc_capabilities) != PTP_RC_OK) {
qWarning("Failed to send capability information to Vita.");
free_pc_capability_info(pc_capabilities);
return false;
}

free_pc_capability_info(pc_capabilities);
}

// Finally, we tell the Vita we are connected
if(VitaMTP_SendHostStatus(device, VITA_HOST_STATUS_Connected) != PTP_RC_OK) {
qWarning("Cannot send host status.");
return false;
}

VitaMTP_Data_Free_Initiator(pc_info);
return true;
}

void DeviceCapability::free_pc_capability_info(capability_info_t *info)
{
delete &info->functions.formats.next_item[-1];
delete &info->functions.next_item[-1];
delete info;
}

capability_info_t *DeviceCapability::generate_pc_capability_info()
{
typedef capability_info::capability_info_function tfunction;
typedef tfunction::capability_info_format tformat;

// TODO: Actually do this based on QCMA capabilities
capability_info_t *pc_capabilities = new capability_info_t;
pc_capabilities->version = "1.0";
tfunction *functions = new tfunction[3]();
tformat *game_formats = new tformat[5]();
game_formats[0].contentType = "vitaApp";
game_formats[0].next_item = &game_formats[1];
game_formats[1].contentType = "PSPGame";
game_formats[1].next_item = &game_formats[2];
game_formats[2].contentType = "PSPSaveData";
game_formats[2].next_item = &game_formats[3];
game_formats[3].contentType = "PSGame";
game_formats[3].next_item = &game_formats[4];
game_formats[4].contentType = "PSMApp";
functions[0].type = "game";
functions[0].formats = game_formats[0];
functions[0].next_item = &functions[1];
functions[1].type = "backup";
functions[1].next_item = &functions[2];
functions[2].type = "systemUpdate";
pc_capabilities->functions = functions[0];
return pc_capabilities;
}
46 changes: 46 additions & 0 deletions capability.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* QCMA: Cross-platform content manager assistant for the PS Vita
*
* Copyright (C) 2013 Codestation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef CAPABILITY_H
#define CAPABILITY_H

extern "C" {
#include <vitamtp.h>
}

class DeviceCapability
{
public:
explicit DeviceCapability() {}
bool exchangeInfo(vita_device_t *device);

//TODO: vita_info_t doesn't retrieve this info, update vitamtp to get it
const char *getVersion() { return ""; }
const char *getProtocol() { return ""; }
const char *getOnlineId() { return "PS Vita"; }
const char *getModelInfo() { return ""; }

private:
capability_info_t *generate_pc_capability_info();
void free_pc_capability_info(capability_info_t *info);

vita_info_t vita_info;
};

#endif // CAPABILITY_H
Loading

0 comments on commit f9347f3

Please sign in to comment.