Commit a109e3d6 authored by Tobias Junghans's avatar Tobias Junghans
Browse files

Use auto keyword where possible

parent 4993e65d
......@@ -547,7 +547,7 @@ void PWFrameBuffer::Private::onStateChanged(void *data, pw_remote_state /*old*/,
{
qInfo() << "remote state: " << pw_remote_state_as_string(state);
PWFrameBuffer::Private *d = static_cast<PWFrameBuffer::Private*>(data);
auto d = static_cast<PWFrameBuffer::Private*>(data);
switch (state) {
case PW_REMOTE_STATE_ERROR:
......
......@@ -105,7 +105,7 @@ bool KrfbXCBEventFilter::nativeEventFilter(const QByteArray &eventType,
if (xdamageBaseEvent == 0) return false; // no xdamage extension
if (eventType == "xcb_generic_event_t") {
xcb_generic_event_t* ev = static_cast<xcb_generic_event_t *>(message);
auto ev = static_cast<xcb_generic_event_t *>(message);
if ((ev->response_type & 0x7F) == (xdamageBaseEvent + XCB_DAMAGE_NOTIFY)) {
// this is xdamage notification
this->fb_owner->handleXDamageNotify(ev);
......@@ -682,7 +682,7 @@ void XCBFrameBuffer::stopMonitor() {
void XCBFrameBuffer::handleXDamageNotify(xcb_generic_event_t *xevent) {
xcb_damage_notify_event_t *xdevt = (xcb_damage_notify_event_t *)xevent;
auto xdevt = (xcb_damage_notify_event_t *)xevent;
QRect r((int)xdevt->area.x, (int)xdevt->area.y,
(int)xdevt->area.width, (int)xdevt->area.height);
......
......@@ -85,7 +85,7 @@ void EventsManager::loadPlugins()
qCDebug(KRFB) << "found plugin at " << data.fileName();
}
EventsPlugin *plugin = factory->create<EventsPlugin>(this);
auto plugin = factory->create<EventsPlugin>(this);
if (plugin) {
m_plugins.insert(data.pluginId(), plugin);
qCDebug(KRFB) << "Loaded plugin with name " << data.pluginId();
......
......@@ -84,7 +84,7 @@ void FrameBufferManager::loadPlugins()
qCDebug(KRFB) << "found plugin at " << data.fileName();
}
FrameBufferPlugin *plugin = factory->create<FrameBufferPlugin>(this);
auto plugin = factory->create<FrameBufferPlugin>(this);
if (plugin) {
m_plugins.insert(data.pluginId(), plugin);
qCDebug(KRFB) << "Loaded plugin with name " << data.pluginId();
......
......@@ -79,7 +79,7 @@ void PendingInvitationsRfbClient::processNewClient()
i18n("Received connection from %1, on hold (waiting for confirmation)",
host));
InvitationsConnectionDialog *dialog = new InvitationsConnectionDialog(nullptr);
auto dialog = new InvitationsConnectionDialog(nullptr);
dialog->setRemoteHost(host);
dialog->setAllowRemoteControl(KrfbConfig::allowDesktopControl());
......@@ -141,10 +141,10 @@ bool PendingInvitationsRfbClient::checkPassword(const QByteArray & encryptedPass
void PendingInvitationsRfbClient::dialogAccepted()
{
InvitationsConnectionDialog *dialog = qobject_cast<InvitationsConnectionDialog *>(sender());
auto dialog = qobject_cast<InvitationsConnectionDialog *>(sender());
Q_ASSERT(dialog);
InvitationsRfbClient *client = new InvitationsRfbClient(m_rfbClient, parent());
auto client = new InvitationsRfbClient(m_rfbClient, parent());
client->setControlEnabled(dialog->allowRemoteControl());
accept(client);
}
......@@ -253,7 +253,7 @@ void RfbServer::pendingClientFinished(RfbClient *client)
rfbNewClientAction RfbServer::newClientHook(rfbClientPtr cl)
{
//qDebug() << "New client";
RfbServer *server = static_cast<RfbServer*>(cl->screen->screenData);
auto server = static_cast<RfbServer*>(cl->screen->screenData);
PendingRfbClient *pendingClient = server->newClient(cl);
connect(pendingClient, &PendingRfbClient::finished,
......@@ -266,7 +266,7 @@ rfbNewClientAction RfbServer::newClientHook(rfbClientPtr cl)
void RfbServer::clientGoneHook(rfbClientPtr cl)
{
//qDebug() << "client gone";
RfbClient *client = static_cast<RfbClient*>(cl->clientData);
auto client = static_cast<RfbClient*>(cl->clientData);
RfbServerManager::instance()->removeClient(client);
client->deleteLater();
......@@ -275,7 +275,7 @@ void RfbServer::clientGoneHook(rfbClientPtr cl)
//static
rfbBool RfbServer::passwordCheck(rfbClientPtr cl, const char *encryptedPassword, int len)
{
PendingRfbClient *client = static_cast<PendingRfbClient*>(cl->clientData);
auto client = static_cast<PendingRfbClient*>(cl->clientData);
Q_ASSERT(client);
return client->checkPassword(QByteArray::fromRawData(encryptedPassword, len));
}
......@@ -283,14 +283,14 @@ rfbBool RfbServer::passwordCheck(rfbClientPtr cl, const char *encryptedPassword,
//static
void RfbServer::keyboardHook(rfbBool down, rfbKeySym keySym, rfbClientPtr cl)
{
RfbClient *client = static_cast<RfbClient*>(cl->clientData);
auto client = static_cast<RfbClient*>(cl->clientData);
client->handleKeyboardEvent(down ? true : false, keySym);
}
//static
void RfbServer::pointerHook(int bm, int x, int y, rfbClientPtr cl)
{
RfbClient *client = static_cast<RfbClient*>(cl->clientData);
auto client = static_cast<RfbClient*>(cl->clientData);
client->handleMouseEvent(bm, x, y);
}
......
......@@ -35,7 +35,7 @@ QString peerAddress(int sock)
if (getpeername(sock, &sa, &salen) == 0) {
if (sa.sa_family == AF_INET) {
struct sockaddr_in *si = (struct sockaddr_in *)&sa;
auto si = (struct sockaddr_in *)&sa;
return QString::fromLatin1(inet_ntoa(si->sin_addr));
}
......@@ -58,7 +58,7 @@ unsigned short peerPort(int sock)
socklen_t salen = sizeof(struct sockaddr);
if (getpeername(sock, &sa, &salen) == 0) {
struct sockaddr_in *si = (struct sockaddr_in *)&sa;
auto si = (struct sockaddr_in *)&sa;
return ntohs(si->sin_port);
}
......@@ -67,14 +67,13 @@ unsigned short peerPort(int sock)
QString localAddress(int sock)
{
const int ADDR_SIZE = 50;
struct sockaddr sa;
struct sockaddr sa{};
socklen_t salen = sizeof(struct sockaddr);
if (getsockname(sock, &sa, &salen) == 0) {
if (sa.sa_family == AF_INET) {
struct sockaddr_in *si = (struct sockaddr_in *)&sa;
auto si = (struct sockaddr_in *)&sa;
return QString::fromLatin1(inet_ntoa(si->sin_addr));
}
......@@ -97,7 +96,7 @@ unsigned short localPort(int sock)
socklen_t salen = sizeof(struct sockaddr);
if (getsockname(sock, &sa, &salen) == 0) {
struct sockaddr_in *si = (struct sockaddr_in *)&sa;
auto si = (struct sockaddr_in *)&sa;
return ntohs(si->sin_port);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment