~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/loader/FTPDirectoryDocument.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
public:
58
58
    FTPDirectoryTokenizer(HTMLDocument*);
59
59
 
60
 
    virtual bool write(const SegmentedString&, bool appendData);
 
60
    virtual void write(const SegmentedString&, bool appendData);
61
61
    virtual void finish();
62
62
    
63
63
    virtual bool isWaitingForScripts() const { return false; }
117
117
    RefPtr<Element> rowElement = m_tableElement->insertRow(-1, ec);
118
118
    rowElement->setAttribute("class", "ftpDirectoryEntryRow", ec);
119
119
   
120
 
    RefPtr<Element> element = m_doc->createElementNS(xhtmlNamespaceURI, "td", ec);
121
 
    element->appendChild(new Text(m_doc, String(&noBreakSpace, 1)), ec);
 
120
    RefPtr<Element> element = m_doc->createElement(tdTag, false);
 
121
    element->appendChild(Text::create(m_doc, String(&noBreakSpace, 1)), ec);
122
122
    if (isDirectory)
123
123
        element->setAttribute("class", "ftpDirectoryIcon ftpDirectoryTypeDirectory", ec);
124
124
    else
129
129
    element->setAttribute("class", "ftpDirectoryFileName", ec);
130
130
    rowElement->appendChild(element, ec);
131
131
    
132
 
    element = m_doc->createElementNS(xhtmlNamespaceURI, "td", ec);
133
 
    element->appendChild(new Text(m_doc, date), ec);
 
132
    element = m_doc->createElement(tdTag, false);
 
133
    element->appendChild(Text::create(m_doc, date), ec);
134
134
    element->setAttribute("class", "ftpDirectoryFileDate", ec);
135
135
    rowElement->appendChild(element, ec);
136
136
    
137
 
    element = m_doc->createElementNS(xhtmlNamespaceURI, "td", ec);
138
 
    element->appendChild(new Text(m_doc, size), ec);
 
137
    element = m_doc->createElement(tdTag, false);
 
138
    element->appendChild(Text::create(m_doc, size), ec);
139
139
    element->setAttribute("class", "ftpDirectoryFileSize", ec);
140
140
    rowElement->appendChild(element, ec);
141
141
}
150
150
    else
151
151
        fullURL.append("/" + filename);
152
152
 
153
 
    RefPtr<Element> anchorElement = m_doc->createElementNS(xhtmlNamespaceURI, "a", ec);
 
153
    RefPtr<Element> anchorElement = m_doc->createElement(aTag, false);
154
154
    anchorElement->setAttribute("href", fullURL, ec);
155
 
    anchorElement->appendChild(new Text(m_doc, filename), ec);
 
155
    anchorElement->appendChild(Text::create(m_doc, filename), ec);
156
156
    
157
 
    RefPtr<Element> tdElement = m_doc->createElementNS(xhtmlNamespaceURI, "td", ec);
 
157
    RefPtr<Element> tdElement = m_doc->createElement(tdTag, false);
158
158
    tdElement->appendChild(anchorElement, ec);
159
159
    
160
160
    return tdElement.release();
235
235
 
236
236
#define localtime_r(x, y) localTimeQt(x, y)
237
237
#elif PLATFORM(WIN_OS) && !defined(localtime_r)
 
238
#if defined(_MSC_VER) && (_MSC_VER >= 1400) 
238
239
#define localtime_r(x, y) localtime_s((y), (x))
 
240
#else /* !_MSC_VER */ 
 
241
#define localtime_r(x,y) (localtime(x)?(*(y)=*localtime(x),(y)):0)
 
242
#endif
239
243
#endif
240
244
 
241
245
static String processFileDateString(const FTPTime& fileTime)
276
280
                return "Yesterday" + timeOfDay;
277
281
        }
278
282
        
279
 
        if (now.tm_mday == 1 && (now.tm_mon == fileTime.tm_mon + 1 || now.tm_mon == 0 && fileTime.tm_mon == 11) &&
 
283
        if (now.tm_mday == 1 && (now.tm_mon == fileTime.tm_mon + 1 || (now.tm_mon == 0 && fileTime.tm_mon == 11)) &&
280
284
            wasLastDayOfMonth(fileTime.tm_year, fileTime.tm_mon, fileTime.tm_mday))
281
285
                return "Yesterday" + timeOfDay;
282
286
    }
303
307
void FTPDirectoryTokenizer::parseAndAppendOneLine(const String& inputLine)
304
308
{
305
309
    ListResult result;
 
310
    CString latin1Input = inputLine.latin1();
306
311
 
307
 
    FTPEntryType typeResult = parseOneFTPLine(inputLine.latin1().data(), m_listState, result);
 
312
    FTPEntryType typeResult = parseOneFTPLine(latin1Input.data(), m_listState, result);
308
313
    
309
314
    // FTPMiscEntry is a comment or usage statistic which we don't care about, and junk is invalid data - bail in these 2 cases
310
315
    if (typeResult == FTPMiscEntry || typeResult == FTPJunkEntry)
364
369
        return true;
365
370
 
366
371
    // Otherwise create one manually
 
372
    tableElement = m_doc->createElement(tableTag, false);
 
373
    m_tableElement = static_cast<HTMLTableElement*>(tableElement.get());
367
374
    ExceptionCode ec;        
368
 
    tableElement = m_doc->createElementNS(xhtmlNamespaceURI, "table", ec);
369
 
    m_tableElement = static_cast<HTMLTableElement*>(tableElement.get());
370
375
    m_tableElement->setAttribute("id", "ftpDirectoryTable", ec);
371
376
 
372
377
    // If we didn't find the table element, lets try to append our own to the body
386
391
 
387
392
    // FIXME: Make this "basic document" more acceptable
388
393
 
389
 
    ExceptionCode ec;
390
394
    
391
 
    RefPtr<Element> bodyElement = m_doc->createElementNS(xhtmlNamespaceURI, "body", ec);
 
395
    RefPtr<Element> bodyElement = m_doc->createElement(bodyTag, false);
392
396
                            
 
397
    ExceptionCode ec;
393
398
    m_doc->appendChild(bodyElement, ec);
394
399
    
395
 
    RefPtr<Element> tableElement = m_doc->createElementNS(xhtmlNamespaceURI, "table", ec);
 
400
    RefPtr<Element> tableElement = m_doc->createElement(tableTag, false);
396
401
    m_tableElement = static_cast<HTMLTableElement*>(tableElement.get());
397
402
    m_tableElement->setAttribute("id", "ftpDirectoryTable", ec);
398
403
 
399
404
    bodyElement->appendChild(m_tableElement, ec);
400
405
}
401
406
 
402
 
bool FTPDirectoryTokenizer::write(const SegmentedString& s, bool /*appendData*/)
 
407
void FTPDirectoryTokenizer::write(const SegmentedString& s, bool /*appendData*/)
403
408
{    
404
409
    // Make sure we have the table element to append to by loading the template set in the pref, or
405
410
    // creating a very basic document with the appropriate table
439
444
    
440
445
    if (!foundNewLine) {
441
446
        m_dest = m_buffer;
442
 
        return false;
 
447
        return;
443
448
    }
444
449
 
445
450
    UChar* start = m_buffer;
460
465
    // Copy the partial line we have left to the carryover buffer
461
466
    if (cursor - start > 1)
462
467
        m_carryOver.append(String(start, cursor - start - 1));
463
 
    
464
 
    return false;
465
468
}
466
469
 
467
470
void FTPDirectoryTokenizer::finish()