• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

  • tdecore
ktimezones.cpp
1 /*
2  This file is part of the KDE libraries
3  Copyright (c) 2005 S.R.Haque <srhaque@iee.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 version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include <config.h>
21 
22 #include <ktimezones.h>
23 #include <kdebug.h>
24 #include <kmdcodec.h>
25 #include <tdeprocess.h>
26 #include <kstringhandler.h>
27 #include <tdetempfile.h>
28 
29 #include <tqdatetime.h>
30 #include <tqfile.h>
31 #include <tqregexp.h>
32 #include <tqstringlist.h>
33 #include <tqtextstream.h>
34 
35 #include <cerrno>
36 #include <climits>
37 #include <cstdlib>
38 #include <cstring>
39 #include <ctime>
40 
41 #define UTC_ZONE "UTC"
42 
51 class AbbreviationsMatch :
52  public KTimezoneDetails
53 {
54 public:
55  AbbreviationsMatch(const TQString &stdZone, const TQString &dstZone = "")
56  {
57  m_stdZone = stdZone;
58  m_dstZone = dstZone;
59  }
60 
61  void parseStarted()
62  {
63  m_foundStd = false;
64  m_foundDst = m_dstZone.isEmpty();
65  }
66 
67  bool test()
68  {
69  return (m_foundStd && m_foundDst);
70  }
71 
72 private:
73  bool m_foundStd;
74  bool m_foundDst;
75  TQString m_stdZone;
76  TQString m_dstZone;
77 
78  virtual void gotAbbreviation(int /*index*/, const TQString &value)
79  {
80  if (m_stdZone == value)
81  {
82  m_foundStd = true;
83  }
84  if (m_dstZone == value)
85  {
86  m_foundDst = true;
87  }
88  }
89 };
90 
94 class DummySource :
95  public KTimezoneSource
96 {
97 public:
98  DummySource() :
99  KTimezoneSource("")
100  {
101  }
102 
103  virtual bool parse(const TQString &/*zone*/, KTimezoneDetails &/*dataReceiver*/) const
104  {
105  return true;
106  }
107 };
108 
112 class OffsetFind :
113  public KTimezoneDetails
114 {
115 public:
116  OffsetFind(unsigned dateTime)
117  {
118  m_dateTime = dateTime;
119  }
120 
121  void parseStarted()
122  {
123  m_transitionTimeIndex = 0;
124  m_localTimeIndex = -1;
125  m_abbrIndex = -1;
126  m_offset = 0;
127  m_isDst = false;
128  m_abbr = UTC_ZONE;
129  }
130 
131  int offset()
132  {
133  return m_offset;
134  }
135 
136  bool isDst()
137  {
138  return m_isDst;
139  }
140 
141  TQString abbreviation()
142  {
143  return m_abbr;
144  }
145 
146 private:
147  unsigned m_dateTime;
148  int m_transitionTimeIndex;
149  int m_localTimeIndex;
150  int m_abbrIndex;
151  int m_offset;
152  bool m_isDst;
153  TQString m_abbr;
154 
155  virtual void gotTransitionTime(int index, unsigned transitionTime)
156  {
157  if (transitionTime <= m_dateTime)
158  {
159  // Remember the index of the transition time that relates to dateTime.
160  m_transitionTimeIndex = index;
161  }
162  }
163 
164  virtual void gotLocalTimeIndex(int index, unsigned localTimeIndex)
165  {
166  if (index == m_transitionTimeIndex)
167  {
168  // Remember the index of the local time that relates to dateTime.
169  m_localTimeIndex = localTimeIndex;
170  }
171  }
172 
173  virtual void gotLocalTime(int index, int gmtOff, bool isDst, unsigned abbrInd)
174  {
175  if (index == m_localTimeIndex)
176  {
177  // Remember the results that relate to gmtOffset.
178  m_offset = gmtOff;
179  m_isDst = isDst;
180  m_abbrIndex = abbrInd;
181  }
182  }
183 
184  virtual void gotAbbreviation(int index, const TQString &value)
185  {
186  if (index == m_abbrIndex)
187  {
188  m_abbr = value;
189  }
190  }
191 };
192 
193 const float KTimezone::UNKNOWN = 1000.0;
194 
195 bool KTimezone::isValidLatitude(float latitude)
196 {
197  return (latitude >= -90.0) && (latitude <= 90.0);
198 }
199 
200 bool KTimezone::isValidLongitude(float longitude)
201 {
202  return (longitude >= -180.0) && (longitude <= 180.0);
203 }
204 
205 KTimezone::KTimezone(
206  TDESharedPtr<KTimezoneSource> db, const TQString& name,
207  const TQString &countryCode, float latitude, float longitude,
208  const TQString &comment) :
209  m_db(db),
210  m_name(name),
211  m_countryCode(countryCode),
212  m_latitude(latitude),
213  m_longitude(longitude),
214  m_comment(comment),
215  d(0)
216 {
217  // Detect duff values.
218  if (m_latitude * m_latitude > 90 * 90)
219  m_latitude = UNKNOWN;
220  if (m_longitude * m_longitude > 180 * 180)
221  m_longitude = UNKNOWN;
222 }
223 
224 KTimezone::~KTimezone()
225 {
226  // FIXME when needed:
227  // delete d;
228 }
229 
230 TQString KTimezone::comment() const
231 {
232  return m_comment;
233 }
234 
235 TQDateTime KTimezone::convert(const KTimezone *newZone, const TQDateTime &dateTime) const
236 {
237  char *originalZone = ::getenv("TZ");
238 
239  // Convert the given localtime to UTC.
240  ::setenv("TZ", m_name.utf8(), 1);
241  tzset();
242  unsigned utc = dateTime.toTime_t();
243 
244  // Set the timezone and convert UTC to localtime.
245  ::setenv("TZ", newZone->name().utf8(), 1);
246  tzset();
247  TQDateTime remoteTime;
248  remoteTime.setTime_t(utc, TQt::LocalTime);
249 
250  // Now restore things
251  if (!originalZone)
252  {
253  ::unsetenv("TZ");
254  }
255  else
256  {
257  ::setenv("TZ", originalZone, 1);
258  }
259  tzset();
260  return remoteTime;
261 }
262 
263 TQString KTimezone::countryCode() const
264 {
265  return m_countryCode;
266 }
267 
268 float KTimezone::latitude() const
269 {
270  return m_latitude;
271 }
272 
273 float KTimezone::longitude() const
274 {
275  return m_longitude;
276 }
277 
278 TQString KTimezone::name() const
279 {
280  return m_name;
281 }
282 
283 int KTimezone::offset(TQt::TimeSpec basisSpec) const
284 {
285  char *originalZone = ::getenv("TZ");
286 
287  // Get the time in the current timezone.
288  TQDateTime basisTime = TQDateTime::currentDateTime(basisSpec);
289 
290  // Set the timezone and find out what time it is there compared to the basis.
291  ::setenv("TZ", m_name.utf8(), 1);
292  tzset();
293  TQDateTime remoteTime = TQDateTime::currentDateTime(TQt::LocalTime);
294  int offset = remoteTime.secsTo(basisTime);
295 
296  // Now restore things
297  if (!originalZone)
298  {
299  ::unsetenv("TZ");
300  }
301  else
302  {
303  ::setenv("TZ", originalZone, 1);
304  }
305  tzset();
306  return offset;
307 }
308 
309 int KTimezone::offset(const TQDateTime &dateTime) const
310 {
311  OffsetFind finder(dateTime.toTime_t());
312  int result = 0;
313  if (parse(finder))
314  {
315  result = finder.offset();
316  }
317  return result;
318 }
319 
320 bool KTimezone::parse(KTimezoneDetails &dataReceiver) const
321 {
322  dataReceiver.parseStarted();
323  bool result = m_db->parse(m_name, dataReceiver);
324  dataReceiver.parseEnded();
325  return result;
326 }
327 
328 KTimezones::KTimezones() :
329  m_zoneinfoDir(),
330  m_zones(0),
331  d(0)
332 {
333  // Create the database (and resolve m_zoneinfoDir!).
334  allZones();
335  m_UTC = new KTimezone(new DummySource(), UTC_ZONE);
336  add(m_UTC);
337 }
338 
339 KTimezones::~KTimezones()
340 {
341  // FIXME when needed:
342  // delete d;
343 
344  // Autodelete behavior.
345  if (m_zones)
346  {
347  for (ZoneMap::ConstIterator it = m_zones->begin(); it != m_zones->end(); ++it)
348  {
349  delete it.data();
350  }
351  }
352  delete m_zones;
353 }
354 
355 void KTimezones::add(KTimezone *zone)
356 {
357  m_zones->insert(zone->name(), zone);
358 }
359 
360 const KTimezones::ZoneMap KTimezones::allZones()
361 {
362  // Have we already done all the hard work? If not, create the cache.
363  if (m_zones)
364  return *m_zones;
365  m_zones = new ZoneMap();
366 
367  // Go read the database.
368  //
369  // On Windows, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones
370  // is the place to look. The TZI binary value is the TIME_ZONE_INFORMATION structure.
371  //
372  // For Unix its all easy except knowing where to look. Try the LSB location first.
373  TQFile f;
374  m_zoneinfoDir = "/usr/share/zoneinfo";
375  f.setName(m_zoneinfoDir + "/zone.tab");
376  if (!f.open(IO_ReadOnly))
377  {
378  kdDebug() << "Can't open " << f.name() << endl;
379  m_zoneinfoDir = "/usr/lib/zoneinfo";
380  f.setName(m_zoneinfoDir + "/zone.tab");
381  if (!f.open(IO_ReadOnly))
382  {
383  kdDebug() << "Can't open " << f.name() << endl;
384  m_zoneinfoDir = ::getenv("TZDIR");
385  f.setName(m_zoneinfoDir + "/zone.tab");
386  if (m_zoneinfoDir.isEmpty() || !f.open(IO_ReadOnly))
387  {
388  kdDebug() << "Can't open " << f.name() << endl;
389 
390  // Solaris support. Synthesise something that looks like a zone.tab.
391  //
392  // /bin/grep -h ^Zone /usr/share/lib/zoneinfo/src/* | /bin/awk '{print "??\t+9999+99999\t" $2}'
393  //
394  // where the country code is set to "??" and the lattitude/longitude
395  // values are dummies.
396  m_zoneinfoDir = "/usr/share/lib/zoneinfo";
397  KTempFile temp;
398  KShellProcess reader;
399  reader << "/bin/grep" << "-h" << "^Zone" << m_zoneinfoDir << "/src/*" << temp.name() << "|" <<
400  "/bin/awk" << "'{print \"??\\t+9999+99999\\t\" $2}'";
401  // Note the use of blocking here...it is a trivial amount of data!
402  temp.close();
403  reader.start(TDEProcess::Block);
404  f.setName(temp.name());
405  if (!temp.status() || !f.open(IO_ReadOnly))
406  {
407  kdDebug() << "Can't open " << f.name() << endl;
408  return *m_zones;
409  }
410  }
411  }
412  }
413 
414  // Parse the zone.tab.
415  TQTextStream str(&f);
416  TQRegExp lineSeparator("[ \t]");
417  TQRegExp ordinateSeparator("[+-]");
418  TDESharedPtr<KTimezoneSource> db(new KTimezoneSource(m_zoneinfoDir));
419  while (!str.atEnd())
420  {
421  TQString line = str.readLine();
422  if (line.isEmpty() || '#' == line[0])
423  continue;
424  TQStringList tokens = KStringHandler::perlSplit(lineSeparator, line, 4);
425  if (tokens.count() < 3)
426  {
427  kdError() << "invalid record: " << line << endl;
428  continue;
429  }
430 
431  // Got three tokens. Now check for two ordinates plus first one is "".
432  TQStringList ordinates = KStringHandler::perlSplit(ordinateSeparator, tokens[1], 2);
433  if (ordinates.count() < 2)
434  {
435  kdError() << "invalid coordinates: " << tokens[1] << endl;
436  continue;
437  }
438 
439  float latitude = convertCoordinate(ordinates[1]);
440  float longitude = convertCoordinate(ordinates[2]);
441 
442  // Add entry to list.
443  if (tokens[0] == "??")
444  tokens[0] = "";
445  KTimezone *timezone = new KTimezone(db, tokens[2], tokens[0], latitude, longitude, tokens[3]);
446  add(timezone);
447  }
448  f.close();
449  return *m_zones;
450 }
451 
455 float KTimezones::convertCoordinate(const TQString &coordinate)
456 {
457  int value = coordinate.toInt();
458  int degrees = 0;
459  int minutes = 0;
460  int seconds = 0;
461 
462  if (coordinate.length() > 11)
463  {
464  degrees = value / 10000;
465  value -= degrees * 10000;
466  minutes = value / 100;
467  value -= minutes * 100;
468  seconds = value;
469  }
470  else
471  {
472  degrees = value / 100;
473  value -= degrees * 100;
474  minutes = value;
475  }
476  value = degrees * 3600 + minutes * 60 + seconds;
477  return value / 3600.0;
478 }
479 
480 const KTimezone *KTimezones::local()
481 {
482  const KTimezone *local = 0;
483 
484  // First try the simplest solution of checking for well-formed TZ setting.
485  char *envZone = ::getenv("TZ");
486  if (envZone)
487  {
488  if (envZone[0] == '\0')
489  {
490  return m_UTC;
491  }
492  else
493  if (envZone[0] == ':')
494  {
495  envZone++;
496  }
497  local = zone(envZone);
498  }
499  if (local)
500  return local;
501 
502  // Try to match /etc/localtime against the list of zoneinfo files.
503  TQFile f;
504  f.setName("/etc/localtime");
505  if (f.open(IO_ReadOnly))
506  {
507  // Compute the MD5 sum of /etc/localtime.
508  KMD5 context("");
509  context.reset();
510  context.update(f);
511  TQIODevice::Offset referenceSize = f.size();
512  TQString referenceMd5Sum = context.hexDigest();
513  f.close();
514  if (!m_zoneinfoDir.isEmpty())
515  {
516  // Compare it with each zoneinfo file.
517  for (ZoneMap::Iterator it = m_zones->begin(); it != m_zones->end(); ++it)
518  {
519  KTimezone *zone = it.data();
520  f.setName(m_zoneinfoDir + '/' + zone->name());
521  if (f.open(IO_ReadOnly))
522  {
523  TQIODevice::Offset candidateSize = f.size();
524  TQString candidateMd5Sum;
525  if (candidateSize == referenceSize)
526  {
527  // Only do the heavy lifting for file sizes which match.
528  context.reset();
529  context.update(f);
530  candidateMd5Sum = context.hexDigest();
531  }
532  f.close();
533  if (candidateMd5Sum == referenceMd5Sum)
534  {
535  // kdError() << "local=" << zone->name() << endl;
536  local = zone;
537  break;
538  }
539  }
540  }
541  }
542  }
543  if (local)
544  return local;
545 
546  // BSD support.
547  TQString fileZone;
548  f.setName("/etc/timezone");
549  if (!f.open(IO_ReadOnly))
550  {
551  kdDebug() << "Can't open " << f.name() << endl;
552 
553  // Solaris support using /etc/default/init.
554  f.setName("/etc/default/init");
555  if (!f.open(IO_ReadOnly))
556  {
557  kdDebug() << "Can't open " << f.name() << endl;
558  }
559  else
560  {
561  TQTextStream ts(&f);
562  ts.setEncoding(TQTextStream::Latin1);
563 
564  // Read the last line starting "TZ=".
565  while (!ts.atEnd())
566  {
567  fileZone = ts.readLine();
568  if (fileZone.startsWith("TZ="))
569  {
570  fileZone = fileZone.mid(3);
571 
572  // kdError() << "local=" << fileZone << endl;
573  local = zone(fileZone);
574  }
575  }
576  f.close();
577  }
578  }
579  else
580  {
581  TQTextStream ts(&f);
582  ts.setEncoding(TQTextStream::Latin1);
583 
584  // Read the first line.
585  if (!ts.atEnd())
586  {
587  fileZone = ts.readLine();
588 
589  // kdError() << "local=" << fileZone << endl;
590  local = zone(fileZone);
591  }
592  f.close();
593  }
594  if (local)
595  return local;
596 
597  // None of the deterministic stuff above has worked: try a heuristic. We
598  // try to find a pair of matching timezone abbreviations...that way, we'll
599  // likely return a value in the user's own country.
600  if (!m_zoneinfoDir.isEmpty())
601  {
602  tzset();
603  AbbreviationsMatch matcher(tzname[0], tzname[1]);
604  int bestOffset = INT_MAX;
605  for (ZoneMap::Iterator it = m_zones->begin(); it != m_zones->end(); ++it)
606  {
607  KTimezone *zone = it.data();
608  int candidateOffset = TQABS(zone->offset(TQt::LocalTime));
609  if (zone->parse(matcher) && matcher.test() && (candidateOffset < bestOffset))
610  {
611  // kdError() << "local=" << zone->name() << endl;
612  bestOffset = candidateOffset;
613  local = zone;
614  }
615  }
616  }
617  if (local)
618  return local;
619  return m_UTC;
620 }
621 
622 const KTimezone *KTimezones::zone(const TQString &name)
623 {
624  if (name.isEmpty())
625  return m_UTC;
626  ZoneMap::ConstIterator it = m_zones->find(name);
627  if (it != m_zones->end())
628  return it.data();
629 
630  // Error.
631  return 0;
632 }
633 
634 KTimezoneDetails::KTimezoneDetails()
635 {
636 }
637 
638 KTimezoneDetails::~KTimezoneDetails()
639 {
640 }
641 
642 void KTimezoneDetails::gotAbbreviation(int /*index*/, const TQString &)
643 {}
644 
645 void KTimezoneDetails::gotHeader(
646  unsigned, unsigned, unsigned,
647  unsigned, unsigned, unsigned)
648 {}
649 
650 void KTimezoneDetails::gotLeapAdjustment(int /*index*/, unsigned, unsigned)
651 {}
652 
653 void KTimezoneDetails::gotLocalTime(int /*index*/, int, bool, unsigned)
654 {}
655 
656 void KTimezoneDetails::gotLocalTimeIndex(int /*index*/, unsigned)
657 {}
658 
659 void KTimezoneDetails::gotIsStandard(int /*index*/, bool)
660 {}
661 
662 void KTimezoneDetails::gotTransitionTime(int /*index*/, unsigned)
663 {}
664 
665 void KTimezoneDetails::gotIsUTC(int /*index*/, bool)
666 {}
667 
668 void KTimezoneDetails::parseEnded()
669 {}
670 
671 void KTimezoneDetails::parseStarted()
672 {}
673 
674 KTimezoneSource::KTimezoneSource(const TQString &db) :
675  m_db(db)
676 {
677 }
678 
679 KTimezoneSource::~KTimezoneSource()
680 {
681 }
682 
683 TQString KTimezoneSource::db()
684 {
685  return m_db;
686 }
687 
688 bool KTimezoneSource::parse(const TQString &zone, KTimezoneDetails &dataReceiver) const
689 {
690  TQFile f(m_db + '/' + zone);
691  if (!f.open(IO_ReadOnly))
692  {
693  kdError() << "Cannot open " << f.name() << endl;
694  return false;
695  }
696 
697  // Structures that represent the zoneinfo file.
698  TQ_UINT8 T, z, i_, f_;
699  struct
700  {
701  TQ_UINT32 ttisgmtcnt;
702  TQ_UINT32 ttisstdcnt;
703  TQ_UINT32 leapcnt;
704  TQ_UINT32 timecnt;
705  TQ_UINT32 typecnt;
706  TQ_UINT32 charcnt;
707  } tzh;
708  TQ_UINT32 transitionTime;
709  TQ_UINT8 localTimeIndex;
710  struct
711  {
712  TQ_INT32 gmtoff;
713  TQ_INT8 isdst;
714  TQ_UINT8 abbrind;
715  } tt;
716  TQ_UINT32 leapTime;
717  TQ_UINT32 leapSeconds;
718  TQ_UINT8 isStandard;
719  TQ_UINT8 isUTC;
720 
721  TQDataStream str(&f);
722  str >> T >> z >> i_ >> f_;
723  // kdError() << "signature: " << TQChar(T) << TQChar(z) << TQChar(i_) << TQChar(f_) << endl;
724  unsigned i;
725  for (i = 0; i < 4; i++)
726  str >> tzh.ttisgmtcnt;
727  str >> tzh.ttisgmtcnt >> tzh.ttisstdcnt >> tzh.leapcnt >> tzh.timecnt >> tzh.typecnt >> tzh.charcnt;
728  // kdError() << "header: " << tzh.ttisgmtcnt << ", " << tzh.ttisstdcnt << ", " << tzh.leapcnt << ", " <<
729  // tzh.timecnt << ", " << tzh.typecnt << ", " << tzh.charcnt << endl;
730  dataReceiver.gotHeader(tzh.ttisgmtcnt, tzh.ttisstdcnt, tzh.leapcnt, tzh.timecnt, tzh.typecnt, tzh.charcnt);
731  for (i = 0; i < tzh.timecnt; i++)
732  {
733  str >> transitionTime;
734  dataReceiver.gotTransitionTime(i, transitionTime);
735  }
736  for (i = 0; i < tzh.timecnt; i++)
737  {
738  // NB: these appear to be 1-based, not zero-based!
739  str >> localTimeIndex;
740  dataReceiver.gotLocalTimeIndex(i, localTimeIndex);
741  }
742  for (i = 0; i < tzh.typecnt; i++)
743  {
744  str >> tt.gmtoff >> tt.isdst >> tt.abbrind;
745  // kdError() << "local type: " << tt.gmtoff << ", " << tt.isdst << ", " << tt.abbrind << endl;
746  dataReceiver.gotLocalTime(i, tt.gmtoff, (tt.isdst != 0), tt.abbrind);
747  }
748 
749  // Make sure we don't run foul of maliciously coded timezone abbreviations.
750  if (tzh.charcnt > 64)
751  {
752  kdError() << "excessive length for timezone abbreviations: " << tzh.charcnt << endl;
753  return false;
754  }
755  TQByteArray array(tzh.charcnt);
756  str.readRawBytes(array.data(), array.size());
757  char *abbrs = array.data();
758  if (abbrs[tzh.charcnt - 1] != 0)
759  {
760  // These abbrevations are corrupt!
761  kdError() << "timezone abbreviations not terminated: " << abbrs[tzh.charcnt - 1] << endl;
762  return false;
763  }
764  char *abbr = abbrs;
765  while (abbr < abbrs + tzh.charcnt)
766  {
767  // kdError() << "abbr: " << abbr << endl;
768  dataReceiver.gotAbbreviation((abbr - abbrs), abbr);
769  abbr += strlen(abbr) + 1;
770  }
771  for (i = 0; i < tzh.leapcnt; i++)
772  {
773  str >> leapTime >> leapSeconds;
774  // kdError() << "leap entry: " << leapTime << ", " << leapSeconds << endl;
775  dataReceiver.gotLeapAdjustment(i, leapTime, leapSeconds);
776  }
777  for (i = 0; i < tzh.ttisstdcnt; i++)
778  {
779  str >> isStandard;
780  // kdError() << "standard: " << isStandard << endl;
781  dataReceiver.gotIsStandard(i, (isStandard != 0));
782  }
783  for (i = 0; i < tzh.ttisgmtcnt; i++)
784  {
785  str >> isUTC;
786  // kdError() << "UTC: " << isUTC << endl;
787  dataReceiver.gotIsUTC(i, (isUTC != 0));
788  }
789  return true;
790 }
KMD5
An adapted C++ implementation of RSA Data Securities MD5 algorithm.
Definition: kmdcodec.h:403
KMD5::update
void update(const char *in, int len=-1)
Updates the message to be digested.
Definition: kmdcodec.h:442
KMD5::hexDigest
TQCString hexDigest()
Returns the value of the calculated message digest in a hexadecimal representation.
Definition: kmdcodec.cpp:903
KMD5::reset
void reset()
Calling this function will reset the calculated message digest.
Definition: kmdcodec.cpp:942
KShellProcess
A class derived from TDEProcess to start child processes through a shell.
Definition: tdeprocess.h:905
KShellProcess::start
virtual bool start(RunMode runmode=NotifyOnExit, Communication comm=NoCommunication)
Starts the process.
Definition: tdeprocess.cpp:1124
KStringHandler::perlSplit
static TQStringList perlSplit(const TQString &sep, const TQString &s, uint max=0)
Split a TQString into a TQStringList in a similar fashion to the static TQStringList function in Qt,...
Definition: kstringhandler.cpp:452
KTempFile
The KTempFile class creates and opens a unique file for temporary use.
Definition: tdetempfile.h:56
KTempFile::status
int status() const
Returns the status of the file based on errno.
Definition: tdetempfile.cpp:141
KTempFile::close
bool close()
Closes the file.
Definition: tdetempfile.cpp:257
KTempFile::name
TQString name() const
Returns the full path and name of the file.
Definition: tdetempfile.cpp:147
KTimezoneDetails
The KTimezoneDetails class contains extended functions related to a timezone.
Definition: ktimezones.h:226
KTimezoneDetails::gotHeader
virtual void gotHeader(unsigned ttIsGmtCnt, unsigned ttIsStdCnt, unsigned leapCnt, unsigned timeCnt, unsigned typeCnt, unsigned charCnt)
Called when the header is seen.
Definition: ktimezones.cpp:645
KTimezoneDetails::parseEnded
virtual void parseEnded()
Always called after all other callbacks.
Definition: ktimezones.cpp:668
KTimezoneDetails::gotLeapAdjustment
virtual void gotLeapAdjustment(int index, unsigned leapTime, unsigned leapSeconds)
Called when a leap second adjustment is seen.
Definition: ktimezones.cpp:650
KTimezoneDetails::gotLocalTime
virtual void gotLocalTime(int index, int gmtOff, bool isDst, unsigned abbrIndex)
Called when a local time is seen.
Definition: ktimezones.cpp:653
KTimezoneDetails::gotIsUTC
virtual void gotIsUTC(int index, bool isUTC)
Called when a UTC/local time indicator is seen.
Definition: ktimezones.cpp:665
KTimezoneDetails::gotLocalTimeIndex
virtual void gotLocalTimeIndex(int index, unsigned localTimeIndex)
Called when a local time index is seen.
Definition: ktimezones.cpp:656
KTimezoneDetails::gotIsStandard
virtual void gotIsStandard(int index, bool isStandard)
Called when a standard/wall time indicator is seen.
Definition: ktimezones.cpp:659
KTimezoneDetails::parseStarted
virtual void parseStarted()
Always called before any other callback.
Definition: ktimezones.cpp:671
KTimezoneDetails::gotTransitionTime
virtual void gotTransitionTime(int index, unsigned transitionTime)
Called when a transition time is seen.
Definition: ktimezones.cpp:662
KTimezoneDetails::gotAbbreviation
virtual void gotAbbreviation(int index, const TQString &abbr)
Called when a timezone abbreviation is seen.
Definition: ktimezones.cpp:642
KTimezoneSource
The KTimezoneSource class contains information source-dependent functions related to a timezone.
Definition: ktimezones.h:53
KTimezoneSource::parse
virtual bool parse(const TQString &zone, KTimezoneDetails &dataReceiver) const
Extract timezone detail information.
Definition: ktimezones.cpp:688
KTimezoneSource::db
virtual TQString db()
Location of system timezone information.
Definition: ktimezones.cpp:683
KTimezone
The KTimezone class contains core functions related to a timezone.
Definition: ktimezones.h:86
KTimezone::latitude
float latitude() const
Returns the latitude of the timezone.
Definition: ktimezones.cpp:268
KTimezone::isValidLatitude
static bool isValidLatitude(float latitude)
A test for a valid latitude.
Definition: ktimezones.cpp:195
KTimezone::convert
TQDateTime convert(const KTimezone *newZone, const TQDateTime &dateTime) const
Convert a date/time (which is interpreted as being localtime in this timezone) into localtime in the ...
Definition: ktimezones.cpp:235
KTimezone::longitude
float longitude() const
Returns the latitude of the timezone.
Definition: ktimezones.cpp:273
KTimezone::name
TQString name() const
Returns the name of the timezone.
Definition: ktimezones.cpp:278
KTimezone::comment
TQString comment() const
Returns any comment for the timezone.
Definition: ktimezones.cpp:230
KTimezone::isValidLongitude
static bool isValidLongitude(float longitude)
A test for a valid longitude.
Definition: ktimezones.cpp:200
KTimezone::UNKNOWN
static const float UNKNOWN
A representation for unknown locations; this is a float that does not represent a real latitude or lo...
Definition: ktimezones.h:92
KTimezone::KTimezone
KTimezone(TDESharedPtr< KTimezoneSource > db, const TQString &name, const TQString &countryCode=TQString(), float latitude=UNKNOWN, float longitude=UNKNOWN, const TQString &comment=TQString())
Create a timezone.
Definition: ktimezones.cpp:205
KTimezone::countryCode
TQString countryCode() const
Returns the two-letter country code of the timezone.
Definition: ktimezones.cpp:263
KTimezone::parse
bool parse(KTimezoneDetails &dataReceiver) const
Extract timezone detail information.
Definition: ktimezones.cpp:320
KTimezone::offset
int offset(TQt::TimeSpec basisSpec=TQt::UTC) const
Returns the current offset of this timezone to UTC or the local timezone in seconds.
Definition: ktimezones.cpp:283
KTimezones::local
const KTimezone * local()
Returns the local timezone.
Definition: ktimezones.cpp:480
KTimezones::zone
const KTimezone * zone(const TQString &name)
Returns the given timezone.
Definition: ktimezones.cpp:622
KTimezones::add
void add(KTimezone *zone)
Add user-defined timezone to database.
Definition: ktimezones.cpp:355
KTimezones::allZones
const ZoneMap allZones()
Return timezone database.
Definition: ktimezones.cpp:360
TDEProcess::Block
@ Block
The application is suspended until the started process is finished.
Definition: tdeprocess.h:182
TDESharedPtr< KTimezoneSource >
endl
kndbgstream & endl(kndbgstream &s)
Does nothing.
Definition: kdebug.h:583

tdecore

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

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.1
This website is maintained by Timothy Pearson.