ProfileEditor.cpp Example File
bbmprofile/src/ProfileEditor.cpp
#include "ProfileEditor.hpp"
#include <QtCore/QFile>
ProfileEditor::ProfileEditor(bb::platform::bbm::UserProfile* userProfile, QObject *parent)
: QObject(parent)
, m_userProfile(userProfile)
{
}
void ProfileEditor::saveStatus(bool busy, const QString &statusMessage)
{
if (!m_userProfile)
return;
m_userProfile->requestUpdateStatus((busy? bb::platform::bbm::UserStatus::Busy : bb::platform::bbm::UserStatus::Available), statusMessage);
}
void ProfileEditor::savePersonalMessage(const QString &personalMessage)
{
if (!m_userProfile)
return;
m_userProfile->requestUpdatePersonalMessage(personalMessage);
}
void ProfileEditor::saveDisplayPicture(const QString &filePath)
{
if (!m_userProfile)
return;
QFile file(filePath);
if (!file.open(QIODevice::ReadOnly))
return;
const QByteArray imageData = file.readAll();
bb::platform::bbm::ImageType::Type imageType = bb::platform::bbm::ImageType::Unsupported;
if (filePath.endsWith(QLatin1String(".jpg"), Qt::CaseInsensitive) ||
filePath.endsWith(QLatin1String(".jpeg"), Qt::CaseInsensitive))
imageType = bb::platform::bbm::ImageType::Jpg;
else if (filePath.endsWith(QLatin1String(".png"), Qt::CaseInsensitive))
imageType = bb::platform::bbm::ImageType::Png;
else if (filePath.endsWith(QLatin1String(".gif"), Qt::CaseInsensitive))
imageType = bb::platform::bbm::ImageType::Gif;
else if (filePath.endsWith(QLatin1String(".bmp"), Qt::CaseInsensitive))
imageType = bb::platform::bbm::ImageType::Bmp;
m_userProfile->requestUpdateDisplayPicture(imageType, imageData);
}