~ubuntu-branches/ubuntu/hardy/steam/hardy

« back to all changes in this revision

Viewing changes to tools/export.pike

  • Committer: Bazaar Package Importer
  • Author(s): Alain Schroeder
  • Date: 2006-11-21 16:03:12 UTC
  • mfrom: (2.1.4 feisty)
  • Revision ID: james.westby@ubuntu.com-20061121160312-nf96y6nihzsyd2uv
Tags: 2.2.31-3
Add patch to prevent inconsistent data after shutdown.

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
  array tokens = (path/"/");
73
73
  dir = tokens[..sizeof(tokens)-2]*"/";
74
74
  Stdio.mkdirhier(dir);
75
 
  
76
 
  mixed err = catch {
77
 
    Stdio.File f = Stdio.File(path, "wct");
78
 
    f->write(content);
79
 
    f->close();
80
 
  };
 
75
 
 
76
  Stdio.File f = Stdio.File(path, "wct");
 
77
  f->write(content);
 
78
  f->close();
81
79
}
82
80
 
83
81
void obj_from_server(object obj, string path) 
154
152
  
155
153
    Stdio.File xml = Stdio.File(outPath + subpath + "/__steam__.xml", "wct");
156
154
    xml->write("<?xml version='1.0' encoding='utf-8'?>\n"+
157
 
               "<folder name=\""+string_to_utf8(subpath)+"\">\n"+
 
155
               "<folder name='"+string_to_utf8(subpath)+"'>\n"+
158
156
               "  <server>\n"+
159
157
               "    <adress>"+mSwitches->server+"</adress>\n"+
160
158
               "    <port>"+mSwitches->port+"</port>\n"+
181
179
  if ( !stringp(fname) )
182
180
    return "__unknown__";
183
181
  fname = replace(fname, ({ "&"}), ({ "und"}));
184
 
  if ( catch(fname = utf8_to_string(fname)) )
185
 
    return "__illegal_file__";
186
 
  return fname;
 
182
  return utf8_to_string(fname);
187
183
}
188
184
 
189
185
void object_from_server(object obj, string subpath, int|void d)
550
546
    else if ( directory == "all" ) {
551
547
      start = mVariables["groups"];
552
548
    }
 
549
    else if ( directory == "all" ) {
 
550
      start = mVariables["groups"];
 
551
    }
553
552
    else if ( objectp(group) )
554
553
      start = group;
555
554
    else if ( directory != "/" ) {
593
592
        f->close();
594
593
      }
595
594
    }
 
595
    if ( directory == "all" ) {
 
596
      array members = send_cmd(start, "get_groups");
 
597
      array rooms = ({ });
 
598
      mapping workrooms = ([ ]);
 
599
 
 
600
      foreach(members, object member) {
 
601
        object grp_wr = send_cmd(member, "query_attribute", "GROUP_WORKROOM");
 
602
        if ( objectp(grp_wr) )
 
603
          rooms += ({ grp_wr });
 
604
      }
 
605
      object steam = send_cmd(start, "lookup", "steam");
 
606
      array users = send_cmd(steam, "get_members");
 
607
      do_store_users(users);
 
608
      foreach(rooms, object room) {
 
609
        workrooms[send_cmd(room, "get_creator")] = room;
 
610
        room_from_server(room, "/"+room->get_identifier());
 
611
        Stdio.File f = Stdio.File(outPath+"/__steam__.xml", "wct");
 
612
        f->write("<?xml version='1.0' encoding='utf-8'?>\n<groups>");
 
613
        foreach(indices(workrooms), object grp) {
 
614
          f->write("<group name='"+grp->get_identifier()+"'>"+
 
615
                   workrooms[grp]->get_identifier()+"</group>\n");
 
616
        }
 
617
        f->write("</groups>");
 
618
        f->close();
 
619
      }
 
620
    }
596
621
    if ( start->get_object_class() & CLASS_GROUP ) {
597
622
      //export group structures
598
623
      array members = send_cmd(start, "get_members");
622
647
    store_objects();
623
648
  }
624
649
  else
625
 
    werror("Failed to connect \n");
 
650
    werror("Failed to connect\n");
626
651
  return 0;
627
652
}
628
653