~ubuntu-branches/ubuntu/raring/ginkgocadx/raring-proposed

« back to all changes in this revision

Viewing changes to src/cadxcore/main/licencia.cpp

  • Committer: Package Import Robot
  • Author(s): Andreas Tille
  • Date: 2012-05-19 11:37:14 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120519113714-13jwx5svm7d4fnsq
Tags: 2.12.0.4889-1
* New upstream version
* debian/control: Standards-Version: 3.9.3 (no changes needed)
* debhelper 9 (control+compat)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *
3
 
 *  $Id$
4
 
 *  Ginkgo CADx Project
5
 
 *
6
 
 *  Copyright 2008-10 MetaEmotion S.L. All rights reserved.
7
 
 *  http://ginkgo-cadx.com
8
 
 *
9
 
 *  This file is licensed under LGPL v3 license.
10
 
 *  See License.txt for details
11
 
 *
12
 
 *
13
 
 */
14
 
#include <api/globals.h>
15
 
#include "licencia.h"
16
 
/*
17
 
inline void GNC::CheckExpiration()
18
 
{
19
 
        const char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
20
 
                "Sep", "Oct", "Nov", "Dec"};
21
 
        char temp [] = GINKGO_EXPIRATION_START;
22
 
        unsigned char i;
23
 
 
24
 
 
25
 
        struct tm tmCompilacion;
26
 
        tmCompilacion.tm_hour = 0;
27
 
        tmCompilacion.tm_isdst = 0;
28
 
        tmCompilacion.tm_min = 0;
29
 
        tmCompilacion.tm_sec = 0;
30
 
        tmCompilacion.tm_wday = 0;
31
 
        tmCompilacion.tm_yday = 0;
32
 
 
33
 
        tmCompilacion.tm_year = atoi(temp + 7)-1900;
34
 
        *(temp + 6) = 0;
35
 
        tmCompilacion.tm_mday = atoi(temp + 4);
36
 
        *(temp + 3) = 0;
37
 
        for (i = 0; i < 12; i++)
38
 
        {
39
 
                if (!strcmp(temp, months[i]))
40
 
                {
41
 
                        tmCompilacion.tm_mon = i;
42
 
                        break;
43
 
                }
44
 
        }
45
 
 
46
 
        time_t compilacion = mktime(&tmCompilacion);
47
 
        time_t actual;
48
 
        time ( &actual );
49
 
 
50
 
        double diferencia = difftime(actual,compilacion);
51
 
 
52
 
        int dias = diferencia/(86400);
53
 
 
54
 
        if ( GINKGO_EXPIRATION_DAYS < dias) {
55
 
                char mensaje[100];
56
 
                sprintf_s(mensaje,"Licencia desde hace %d dias",(GINKGO_EXPIRATION_DAYS - dias));
57
 
                throw LicenseException(mensaje);
58
 
        }
59
 
 
60
 
}
61
 
 
62
 
inline const std::string GNC::GetFormattedExpirationDate()
63
 
{
64
 
        if (GINKGO_EXPIRATION_DAYS > 0) {
65
 
                const char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
66
 
                        "Sep", "Oct", "Nov", "Dec"};
67
 
                char temp [] = GINKGO_EXPIRATION_START;
68
 
                unsigned char i;
69
 
 
70
 
 
71
 
                struct tm tmCompilacion;
72
 
                tmCompilacion.tm_hour = 0;
73
 
                tmCompilacion.tm_isdst = 0;
74
 
                tmCompilacion.tm_min = 0;
75
 
                tmCompilacion.tm_sec = 0;
76
 
                tmCompilacion.tm_wday = 0;
77
 
                tmCompilacion.tm_yday = 0;
78
 
 
79
 
                tmCompilacion.tm_year = atoi(temp + 7)-1900;
80
 
                *(temp + 6) = 0;
81
 
                tmCompilacion.tm_mday = atoi(temp + 4);
82
 
                *(temp + 3) = 0;
83
 
                for (i = 0; i < 12; i++)
84
 
                {
85
 
                        if (!strcmp(temp, months[i]))
86
 
                        {
87
 
                                tmCompilacion.tm_mon = i;
88
 
                                break;
89
 
                        }
90
 
                }
91
 
 
92
 
                time_t compilacion = mktime(&tmCompilacion);
93
 
                double expiration = compilacion + (GINKGO_EXPIRATION_DAYS * 86400);
94
 
                char fechaExpiracion[100];
95
 
                compilacion = (time_t)expiration;
96
 
                struct tm* tmExpiracion = localtime_s(&compilacion);
97
 
 
98
 
                strftime(fechaExpiracion,100,"%d/%m/%Y",tmExpiracion);
99
 
                return fechaExpiracion;
100
 
        }
101
 
        return "Sin límite";
102
 
 
103
 
}
104
 
*/
105