• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KIO

  • sources
  • kde-4.12
  • kdelibs
  • kio
  • kssl
ksslutils.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE project
2  *
3  * Copyright (C) 2000,2001 George Staikos <staikos@kde.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 
22 #include "ksslutils.h"
23 
24 #include <QtCore/QString>
25 #include <kglobal.h>
26 #include <klocale.h>
27 #include <QtCore/QDate>
28 
29 #include "kopenssl.h"
30 
31 #ifdef KSSL_HAVE_SSL
32 // This code is mostly taken from OpenSSL v0.9.5a
33 // by Eric Young
34 QDateTime ASN1_UTCTIME_QDateTime(ASN1_UTCTIME *tm, int *isGmt) {
35 QDateTime qdt;
36 char *v;
37 int gmt=0;
38 int i;
39 int y=0,M=0,d=0,h=0,m=0,s=0;
40 QDate qdate;
41 QTime qtime;
42 
43  i = tm->length;
44  v = (char *)tm->data;
45 
46  if (i < 10) goto auq_err;
47  if (v[i-1] == 'Z') gmt=1;
48  for (i=0; i<10; ++i)
49  if ((v[i] > '9') || (v[i] < '0')) goto auq_err;
50  y = (v[0]-'0')*10+(v[1]-'0');
51  if (y < 50) y+=100;
52  M = (v[2]-'0')*10+(v[3]-'0');
53  if ((M > 12) || (M < 1)) goto auq_err;
54  d = (v[4]-'0')*10+(v[5]-'0');
55  h = (v[6]-'0')*10+(v[7]-'0');
56  m = (v[8]-'0')*10+(v[9]-'0');
57  if ( (v[10] >= '0') && (v[10] <= '9') &&
58  (v[11] >= '0') && (v[11] <= '9'))
59  s = (v[10]-'0')*10+(v[11]-'0');
60 
61  // localize the date and display it.
62  qdate.setYMD(y+1900, M, d);
63  qtime.setHMS(h,m,s);
64  qdt.setDate(qdate); qdt.setTime(qtime);
65  auq_err:
66  if (isGmt) *isGmt = gmt;
67 return qdt;
68 }
69 
70 
71 QString ASN1_UTCTIME_QString(ASN1_UTCTIME *tm) {
72  QString qstr;
73  int gmt;
74  QDateTime qdt = ASN1_UTCTIME_QDateTime(tm, &gmt);
75  qstr = KGlobal::locale()->formatDateTime(qdt, KLocale::LongDate, true);
76  if (gmt) {
77  qstr += ' ';
78  qstr += i18n("GMT");
79  }
80  return qstr;
81 }
82 
83 
84 QString ASN1_INTEGER_QString(ASN1_INTEGER *aint) {
85 char *rep = KOSSL::self()->i2s_ASN1_INTEGER(NULL, aint);
86 QString yy = rep;
87 KOSSL::self()->OPENSSL_free(rep);
88 return yy;
89 }
90 
91 
92 #endif
93 
i18n
QString i18n(const char *text)
QString
klocale.h
M
#define M(h, p)
kglobal.h
ksslutils.h
KLocale::formatDateTime
QString formatDateTime(const QDateTime &dateTime, DateFormat format=ShortDate, bool includeSecs=false) const
KGlobal::locale
KLocale * locale()
QDateTime
KLocale::LongDate
kopenssl.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:50:03 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal